DFDX,_DFDY(3G)
β¨ dFdx, _dFdy β the partial derivative girlies β¨
okay bestie, pull up a chair because we're talking about dFdx and dFdy β that's section 3G of the manual, the OpenGL shading language girlies. they're giving math, they're giving fragment shader only, they're giving derivative and honestly? iconic. π
π NAME π
dFdx, _dFdy β return the partial derivative of an argument with respect to x or y. that's it. that's the whole vibe. πΈ
π¦ DECLARATION π¦
here's the whole lineup, no notes:
genType dFdx(genType p);
genType dFdy(genType p);
genType dFdxCoarse(genType p);
genType dFdyCoarse(genType p);
genType dFdxFine(genType p);
genType dFdyFine(genType p);
six whole functions. a whole family. they ate. π
π PARAMETERS π
pβ the expression you want the partial derivative of. that's the one. that's the girl. β¨
π DESCRIPTION π
okay so first thing's first, no cap: these are available only in the fragment shader. fragment shader only. if you're in a vertex shader trying to call these, bestie, it's not gonna happen. π
what they do: they return the partial derivative of the expression p with respect to the window $x$ coordinate β that's the dFdx* girlies β and with respect to the window $y$ coordinate β that's the dFdy* girlies. π«
the fine girlies π§
dFdxFine and dFdyFine calculate derivatives using local differencing based on the value of p for the current fragment and its immediate neighbor(s). very precise. very local. very main character energy. β
the coarse girlies π
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. like, she might show up, she might not, no promises. π
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. less work, same energy. lowkey efficient.
the ones that pick for you π
dFdx returns either dFdxCoarse or dFdxFine. dFdy returns either dFdyCoarse or dFdyFine.
the implementation gets to choose which calculation to perform based upon factors such as performance or the value of the API GL_FRAGMENT_SHADER_DERIVATIVE_HINT hint. so basically it's the implementation's choice and she's making it based on β¨vibesβ¨ (and performance. and the hint.)
the danger zone π
be careful bestie, this part matters!!
Expressions that imply higher order derivatives such as dFdx(dFdx(n)) have undefined results. same for mixed-order derivatives such as dFdx(dFdy(n)). undefined. do not do it. π
βοΈ
It is assumed that the expression p is continuous, and therefore expressions evaluated via non-uniform control flow may be undefined. keep it continuous or keep it undefined, your call. π
π VERSION SUPPORT π
the columns are OpenGL Shading Language Version: 1.10, 1.20, 1.30, 1.40, 1.50, 3.30, 4.00, 4.10, 4.20, 4.30, 4.40, 4.50. and here's who shows up where:
dFdxβ β in1.10, β in1.20, β in1.30, β in1.40, β in1.50, β in3.30, β in4.00, β in4.10, β in4.20, β in4.30, β in4.40, β in4.50. she's been here since day one, fr fr. πdFdyβ β in1.10, β in1.20, β in1.30, β in1.40, β in1.50, β in3.30, β in4.00, β in4.10, β in4.20, β in4.30, β in4.40, β in4.50. same girl, different axis. πdFdxCoarse,dFdxFine,dFdyCoarse,dFdyFineβ-in1.10,-in1.20,-in1.30,-in1.40,-in1.50,-in3.30,-in4.00,-in4.10,-in4.20,-in4.30,-in4.40, β in4.50.
so the coarse/fine girlies? 4.50 and later only. late bloomers and they're thriving. π·
π SEE ALSO π
fwidth()glHint()
go read those next, bestie, they're in the same universe. π«Ά
π COPYRIGHT π
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/.
Copyright Β© 2011-2014 Khronos Group
okay that's the whole page, you're welcome, go write a shader about it. πβ¨
that's a wrap from your girl β source [FIXME: source], dated 01/03/2018, DFDX, DFDY(3G). mwah, bye bestie π
ππ¦
π¦ where this page comes from
- ubuntu jammy: opengl-4-man-doc 1.0~svn33624-1 Β· SGI-Free-Software-B-License-2
- ubuntu noble: opengl-4-man-doc 1.0~svn33624-1 Β· SGI-Free-Software-B-License-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms