Wednesday 7 September 2011

ddx and ddy HLSL Intrinsic Function

The ddx and ddy functions return the partial derivatives of a given value with respect to screen coordinates.
In other words: the slope of the function described by the value. Or in other words again: the rate at which a given value changes across the screen.
For example ddx( position ) will tell you how much the surface slopes either left or right. So normalize( cross( ddx(position), ddy(position) ) ) returns a normal to the surface.

No comments:

Post a Comment