Another way to find the perpendicular vector @ 7:00 would be to just use the (Y, -X) of the first vector as the (X, Y) of the second rather than offsetting the Sin & Cos. It comes to the same instruction count, but generally it's best to minimize the use of trigonometric functions in materials as they are relatively expensive compared to other math.
Very helpful tutorial! This is how more UE5 tutorials should be; it makes it so simple that it should really be in UE5 by default for how important, common, and easy-to-miss this issue is.
Thanks! It turns out there is a pre-made node that you can use, called "custom rotator" that does this - But I think it's still good to know the how and why behind it anyway.
Turns out this is more or less what you'd find inside the premade "custom rotator" material function so you probably won't need to create the node setup from scratch normally - but I do think it's still important to understand the how and why it works and why it matters.
Dear Sir! I struggle a lot. Do You know how to make a rotator inside POM material? There are some problems like the Height map and normal direction, and there is not much info about rotation Parallaxa in internet.
At the very least I think it's valuable to fully understand the unit circle, and the basic relationships between Sin, Cos and Tan of a triangle. This will help a lot when dealing with all sorts of problems.
Quixel seem to have their own setup in the megascans master material (in the MapAdjustments material function), does the setup they use achieve the same result as what you've achieved here? Thanks very much
Yes. They are using another custom rotator node to rotate the RG channels of the normal map inversely from the base rotation. Inside the custom rotator node, the math is essentially the same as what I built here. Results and performance should be identical.
Firstly, thank you so much for this incredible tutorial, it was extremely helpful as I couldn't find info on this anywhere else. But after watching and reflecting on it I still have a question. Why do normal maps ""turn around"" when multiplied by -1 instead of turning black like a regular texture would do?
Because normal vectors are in -1 to 1 space. Instead of thinking of normals as colors, think of the RGB values as a position in a 3D space which the normal vector points towards.
It is a named re-route node. Basically allows you to take an input and name it like declaring a variable, then recall that name. It just makes the node graph less spaghetti.
The best option is probably to combine the two rotational axis into one first, then apply the rotation after the fact using the combined axis. normalize((Va + Vb) / 2 ) This will give you a new vector halfway between both axis to rotate around.
@@TechArtAlex Yeah, combined axis is a very good choice for uniform rotation, but non-uniform rotation does not always work correctly due to the influence of components on each other. With vertices it's easy to create a chain of sequential actions to solve this problem, but it doesn't work with normals. Or maybe I'm missing something by trying to bring the rotation vector to the combined axis.
If I'm understanding your issue correctly, you would need to use the formula for compositing two axis-angle rotations or use quaternions. The former will allow you to input not just two rotational axis, but also two angles and effectively apply them sequentially into a single outcome. The latter allows the rotations to be combined via simply multiplication, but for that you would use the formula to convert axis-angle to quaternions, and then back again.
I chose to be a 3D artist to escape from math, wtf!! lol, wish i paid more attention at math classes, i hate math. but this level and quality of information is very hard to come by for free, thanks for sharing
@@TechArtAlex math can be fun, yeah, when the results turn out good like this, it is satisfying, schools make math a chore. It's getting interesting making shaders.
Rotating in the shader is not expensive, because it is done purely on the GPU. Rotating an object outside of the shader requires both the CPU and GPU to do what the GPU could've done by itself. There are lots of cases where you might want to rotate in the shader, for example to reduce tiling on a landscape material. Some of these cases would be impossible to do outside of the shader. All that said. there are exceptions, and every project is different. Thanks for watching.
Another way to find the perpendicular vector @ 7:00 would be to just use the (Y, -X) of the first vector as the (X, Y) of the second rather than offsetting the Sin & Cos. It comes to the same instruction count, but generally it's best to minimize the use of trigonometric functions in materials as they are relatively expensive compared to other math.
thank you for this essential tutorial :)
Thanks for watching!
Your explanations are so crystal clear and easy to understand. Love it!👍🏻
Thanks!
Very helpful tutorial! This is how more UE5 tutorials should be;
it makes it so simple that it should really be in UE5 by default for how important, common, and easy-to-miss this issue is.
Thanks! It turns out there is a pre-made node that you can use, called "custom rotator" that does this - But I think it's still good to know the how and why behind it anyway.
Amazing video! Thank you!
Thanks!
Thank you very much for this awesome tutorial !!
Thanks!
Nicely done, though I'd need to watch this a few hundred more times before I'd able to reproduce it adhoc.
Turns out this is more or less what you'd find inside the premade "custom rotator" material function so you probably won't need to create the node setup from scratch normally - but I do think it's still important to understand the how and why it works and why it matters.
man, thanks a lot! your tuts are pure gold!
Dear Sir! I struggle a lot. Do You know how to make a rotator inside POM material? There are some problems like the Height map and normal direction, and there is not much info about rotation Parallaxa in internet.
Yes, you would need to alter the node as seen here.
forums.unrealengine.com/t/proper-way-to-rotate-a-pom-parallax-occlusion-mapping/384661
Super cool video, mate. Happy holidays!
Thanks, Happy Holidays!
Would you recommend learning trigonometry for understanding shaders?
At the very least I think it's valuable to fully understand the unit circle, and the basic relationships between Sin, Cos and Tan of a triangle. This will help a lot when dealing with all sorts of problems.
lmao, I never even considered this. Nice one thanks for showing us :)
Thanks for watching!
Quixel seem to have their own setup in the megascans master material (in the MapAdjustments material function), does the setup they use achieve the same result as what you've achieved here? Thanks very much
Yes. They are using another custom rotator node to rotate the RG channels of the normal map inversely from the base rotation. Inside the custom rotator node, the math is essentially the same as what I built here. Results and performance should be identical.
Fantastic! Thank you sir!
Happy to help!
how do you move the light inside the viewport at 1:00?
Hold down L and then click and drag.
Thank you very much for the tutorial, but I don't understand what for "Add" node between "RotateAboutAxis" and NormalMap ?
I can't remember the mathematical reason off the top of my head, but I know that it will not work if you don't add them together.
Extremely helpful, thank you!🙂
Happy to help, thanks for watching!
Firstly, thank you so much for this incredible tutorial, it was extremely helpful as I couldn't find info on this anywhere else. But after watching and reflecting on it I still have a question. Why do normal maps ""turn around"" when multiplied by -1 instead of turning black like a regular texture would do?
Because normal vectors are in -1 to 1 space. Instead of thinking of normals as colors, think of the RGB values as a position in a 3D space which the normal vector points towards.
What's the purple "Axis" node during the 3D portion? Still learning nuances of UE5 shading...
It is a named re-route node. Basically allows you to take an input and name it like declaring a variable, then recall that name. It just makes the node graph less spaghetti.
Well done. Thank you.
Thanks for watching!
3D rotation works great for a single axis, but how to sum rotations across multiple axes?
The best option is probably to combine the two rotational axis into one first, then apply the rotation after the fact using the combined axis.
normalize((Va + Vb) / 2 )
This will give you a new vector halfway between both axis to rotate around.
@@TechArtAlex Yeah, combined axis is a very good choice for uniform rotation, but non-uniform rotation does not always work correctly due to the influence of components on each other. With vertices it's easy to create a chain of sequential actions to solve this problem, but it doesn't work with normals.
Or maybe I'm missing something by trying to bring the rotation vector to the combined axis.
If I'm understanding your issue correctly, you would need to use the formula for compositing two axis-angle rotations or use quaternions. The former will allow you to input not just two rotational axis, but also two angles and effectively apply them sequentially into a single outcome. The latter allows the rotations to be combined via simply multiplication, but for that you would use the formula to convert axis-angle to quaternions, and then back again.
@@TechArtAlex Yes, compositing two axis-angle rotations is what I needed. Thanks a lot for the tip!
I chose to be a 3D artist to escape from math, wtf!! lol, wish i paid more attention at math classes, i hate math. but this level and quality of information is very hard to come by for free, thanks for sharing
There is no escape from math I'm afraid. Thanks for watching!
@@TechArtAlex math can be fun, yeah, when the results turn out good like this, it is satisfying, schools make math a chore. It's getting interesting making shaders.
Great video but it is really difficult to see the nodes on your graph clearly.
I'll keep that in mind and try to zoom in more in the future. Thanks!
nice vid! more math vids!
Thanks!
Why do you even want to rotate something in the shader? AFAIK its expensive AF...
Rotating in the shader is not expensive, because it is done purely on the GPU. Rotating an object outside of the shader requires both the CPU and GPU to do what the GPU could've done by itself. There are lots of cases where you might want to rotate in the shader, for example to reduce tiling on a landscape material. Some of these cases would be impossible to do outside of the shader.
All that said. there are exceptions, and every project is different. Thanks for watching.