fdCurvature
The value, slope and curvature of any field at a point: value, dx, dy and curvature.
fdCurvature(sampleAt: (p: Expr) => Expr, p: Expr, eps: number, hint: string = 'fd'): {value: Expr; dx: Expr; dy: Expr; curvature: Expr}
Import materials from shaders/std and use materials.fdCurvature.
fdSlope with two more taps. The slopes are centred, so they sit on the point rather than half a step past it, and curvature is the field's Laplacian: negative on a crest, positive in a crease, zero on a flat or a plane. Scale it by a gain for a cavity shade that darkens creases and lifts crests. eps is the tap distance in the point's units.
Parameters
| Name | Type | Notes |
|---|---|---|
sampleAt | (p: Expr) => Expr | |
p | Expr | |
eps | number | |
hint | string | Optional. Default 'fd'. |
Example
const relief = fdCurvature(cloth, q, 0.004)
const cavity = clamp(sub(1, mul(relief.curvature, 0.005)), 0.6, 1.1)
Tip. Five taps of the field per pixel. Keep the field cheap.
See also
fdSlope— The value and slope of any field at a point:value,dxanddy.nudgeNormal— Tilts a normal by a slope in x and y, turning a height field into relief.