DDX - returns approximate partial derivative with respect to window-space X.
vector1 ddx(vector1 a); vector2 ddx(vector2 a); vector3 ddx(vector3 a); vector4 ddx(vector4 a);
- Vector or scalar of which to approximate the partial derivative with respect to window-space X.
Returns approximate partial derivative of a with respect to the window-space (horizontal) xcoordinate.
For vectors, the returned vector contains the approximate partial derivative of each element of the input vector.
This function is only available in fragment program profiles (but not all of them).
The specific way the partial derivative is computed is implementation-dependent. Typically fragments are rasterized in 2x2 arrangements of fragments (called quad-fragments) and the partial derivatives of a variable is computed by differencing with the adjacent horizontal fragment in the quad-fragment.
The partial derivative computation may incorrect when ddx is used in control flow paths where not all the fragments within a quad-fragment have branched the same way.
The partial derivative computation may be less exact (wobbly) when the variable is computed based on varying parameters interpolated with centroid interpolation.