GLSL built-in function

dFdy()

Estimates the rate of change across screen-space fragment y.

Demo version: GLSL ES 1.00 / WebGL 1Demo stage: Fragment

Syntax

genType dFdy(genType p)

genType means float / vec2 / vec3 / vec4; matching placeholders use the same type.

Parameters

p
Packed unsigned integer

Return value

An approximate screen-space y derivative for each component of p, with the same type as p.

Live example

Edit the code and the preview updates as you type.

What dFdy does

Estimates the rate of change across screen-space fragment y.

Read the preview

The derivative of sin(y*24.0) changes with row, creating horizontal color bands. Set both 24.0 values to 8.0 for wider bands with the same normalization.

Core call

abs(dFdy(sin(y*24.0)))*u_resolution.y/24.0;

This is screen-space y, not the world-space y axis of a model.

Experiment

Use sin(x*24.0) instead of sin(y*24.0) in dFdy. Since neighboring rows then receive the same input, the background becomes uniform apart from the plotted zero line.

Specification

GLSL ES 1.00 built-in functions, chapter 8

Related functions