dpdx
How much a value changes from this pixel to the next one to the right.
dpdx(x: Val): Expr
Import math from shaders/std and use math.dpdx.
Works on numbers and vectors. Use it to measure how fast something moves across the screen: a refracted lookup, a reflected direction, a field. Read it before any guarded branch. Derivatives exist only in a pixel body (paint, effect, surface): a compute input cannot use them.
Parameters
| Name | Type | Notes |
|---|---|---|
x | Val |
Example
const stepX = local(dpdx(lookupUV), 'stepX')
Tip. Derivatives are only legal outside per-pixel branches: wrap the result in
local()before the guard and pass that local toguardedas a dep.