Builtin Library
README.md
sdf.gradient (procNode)
The unit direction a shape's distance grows fastest, by central difference, as a Field<Vec3>: the outward surface normal on the surface, and the direction away from it anywhere else.
Inputs
sdf(Sdf): The shape whose distance is differenced.eps(Float, default 0.0001): Half the width of each difference, in metres: the shape is read this far either side of the point along each axis.up(Bool, default false): Where the distance is flat the direction is +Y when this is on, and the zero vector when it is off.
Outputs
field(Field<Vec3>): the unit direction, a field of position. field.substitute reads it at a geometry's points.
It reads the shape six times per element.
Example
local shape = g.sdf.sphere({ radius = 0.5 })
local pts = g.points.grid({ countX = 4, countZ = 4, spacing = 0.25 })
pts.point.N = g.field.substitute({ field = g.sdf.gradient({ sdf = shape }), position = pts.point.P })