Can't wait for next video! Got a question about HLSL and UE Materials- What are the main advantages in using HLSL code with the "Custom" node over writing the same logic with built in Material Graph nodes? Is it more performant?
Is Saturate node better than standard clamp for limiting the range from 0 to 1? What would the difference be, does Saturate normalizes the color values or something?
Good question. The saturate operation is free - meaning that the graphics hardware can usually do it without requiring any math/calculations. Clamp, on the other hand, has a math/performance cost. So if you need to clamp between zero and one, saturate is a better choice. But if you need to clamp between some other values, clamp is what you use. Having said that, most shader compilers are smart enough to recognize that if use you clamp and give it a 0 to 1 range, they'll replace that with saturate automatically, under the hood for you. So if you try to measure the performance difference between the two, it would probably be the same.
If the Sample Gradient is linear vertically and non-dynamic as color values, isn't it better to just sample a Color Curve from external asset where you can define the colors and have much cleaner and simpler Shader logic?
Just what I needed!
love you
Thanks a lot! Perhaps the big gradient node can be replaced with a low-resolution texture.
Can't wait for next video!
Got a question about HLSL and UE Materials- What are the main advantages in using HLSL code with the "Custom" node over writing the same logic with built in Material Graph nodes? Is it more performant?
Mostly it's just the option to do things in code that aren't possible to do in the graph - like for loops.
Is Saturate node better than standard clamp for limiting the range from 0 to 1?
What would the difference be, does Saturate normalizes the color values or something?
Good question. The saturate operation is free - meaning that the graphics hardware can usually do it without requiring any math/calculations. Clamp, on the other hand, has a math/performance cost. So if you need to clamp between zero and one, saturate is a better choice. But if you need to clamp between some other values, clamp is what you use. Having said that, most shader compilers are smart enough to recognize that if use you clamp and give it a 0 to 1 range, they'll replace that with saturate automatically, under the hood for you. So if you try to measure the performance difference between the two, it would probably be the same.
If the Sample Gradient is linear vertically and non-dynamic as color values, isn't it better to just sample a Color Curve from external asset where you can define the colors and have much cleaner and simpler Shader logic?
Yes, probably.