In complex shader effects, you might want to reduce the complexity of a calculation based on distance. Calculating distance explicitly can be expensive or inaccurate in complex projection spaces.
ddx(normal) approximates screen-space curvature. Use it to deposit “dirt” in concave creases or wear on convex edges. It’s physically inspired but runs at the cost of a few ALU ops. derivative shaders
Derivative shaders, also known as derivative functions or simply derivatives in the context of shaders, refer to a specific set of functions available in shading languages (like HLSL for DirectX or GLSL for OpenGL) that allow for the calculation of the rate of change of a texture's value with respect to the texture coordinates. These are particularly useful for effects that require detailed control over texture sampling and filtering. In complex shader effects, you might want to