dFdx, dFdy

From OpenGL Reference
Jump to navigation Jump to search

Return the partial derivative of an argument with respect to x or y.

Declaration[edit]

genType dFdx( genType p );
genType dFdy( genType p );
genType dFdxCoarse( genType p );
genType dFdyCoarse( genType p );
genType dFdxFine( genType p );
genType dFdyFine( genType p );


Parameters[edit]

p - Specifies the expression of which to take the partial derivative.


Description[edit]

Available only in the fragment shader, these functions return the partial derivative of expression p with respect to the window [math]x[/math] coordinate (for dFdx* ) and [math]y[/math] coordinate (for dFdy* ).

 dFdxFine and dFdyFine calculate derivatives using local differencing based on the value of p for the current fragment and its immediate neighbor(s).

 dFdxCoarse and dFdyCoarse calculate derivatives using local differencing based on the value of p for the current fragment's neighbors, and will possibly, but not necessarily, include the value for the current fragment. That is, over a given area, the implementation can compute derivatives in fewer unique locations than would be allowed for the corresponding dFdxFine and dFdyFine functions.

 dFdx returns either dFdxCoarse or dFdxFine . dFdy returns either dFdyCoarse or dFdyFine . The implementation may choose which calculation to perform based upon factors such as performance or the value of the API GL_FRAGMENT_SHADER_DERIVATIVE_HINT hint.

Expressions that imply higher order derivatives such asdFdx(dFdx(n))have undefined results, as do mixed-order derivatives such asdFdx(dFdy(n)). It is assumed that the expression p is continuous and therefore, expressions evaluated via non-uniform control flow may be undefined.

Version Support[edit]

dFdx 1.1+
dFdy 1.1+
dFdxCoarse, dFdxFine, dFdyCoarse, dFdyFine 4.5+

See Also[edit]

 fwidth , glHint 


Copyright[edit]

Copyright© 2011-2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.