dFdy
Calculates the rate of change or gradient of a value in the screen-space Y-direction (vertical). It answers, 'How much does this value change when moving one pixel down?', providing the vertical component of the screen-space derivative.
Core Advantages
Works in tandem with dFdx to provide the complete 2D screen-space gradient. This combination is essential for direction-agnostic calculations (like fwidth) and unlocks a powerful, native GPU hardware feature for advanced effects.
Common Uses
Paired with dFdx for robust procedural anti-aliasing on any shape.
Essential for accurate texture Mipmap level selection by analyzing UV changes in both axes.
Used within fwidth to create stable wireframe rendering by detecting all triangle edges.
Calculating blend weights in advanced techniques like Triplanar Mapping for seamless texture transitions.
How to adjust
The output is proportional to the input's vertical 'frequency'. For instance, more horizontal stripes (a higher frequency in the Y-axis) will produce a larger dFdy result, automatically strengthening anti-aliasing. It's sensitive to vertical perspective; for a floor plane, the dFdy of its world position will increase as it recedes into the distance.
Code Examples
1// p can be UVs, world position, or any other value computed in the fragment shader
2const gradientY = dFdy( p );