Builtin Library
README.md
sdf.displace (procNode)
The surface pushed in and out by a field evaluated at each point of space; roughens a shape into rock or bark. A shape is a field of position: nothing is evaluated until something reads it, such as sdf.mesh, sdf.sample or field.substitute.
Inputs
sdf(Sdf): The shape being roughened.amount(Field<Float> | Float): How far the surface moves at each point, a field of position: wire sdf.position into field.noise and field.noise into here, and the noise is evaluated at each point of space.scale(Float, default 1.0): Multipliesamountbefore it moves the surface. Negative pushes the surface the other way. The bounds grow by its magnitude.
Outputs
sdf(Sdf): the shape, a record offield(the signed distance at each point of space, negative inside) andbounds({ min, max }, the box the shape stays inside).
The field is the shape's distance less scale * amount: a positive amount moves the surface outward. The bounds grow by abs(scale) on every side, so an amount that stays within -1..1 keeps the shape inside them.
Example
local shape = g.sdf.sphere({ radius = 0.5 })
local bumps = g.field.noise({ position = g.sdf.position(), frequency = 4, kind = "gradient" })
local rough = g.sdf.displace({ sdf = shape, amount = bumps, scale = 0.05 })
local mesh = g.sdf.mesh({ sdf = rough, resolution = 24 }).geometry