Builtin Library
README.md
sdf.union (procNode)
Both shapes as one solid: the minimum of their distances. With blend above 0 the two merge with a fillet, the smooth union that joins two forms into one. A shape is a field of position: nothing is evaluated until something reads it, such as sdf.mesh, sdf.sample or field.substitute.
Inputs
a(Sdf): One of the two shapes. Union is symmetric.b(Sdf): The other shape.blend(Float, default 0.0): How wide the fillet where the two shapes meet is, in the shapes' own units. At 0 the two meet at a hard crease. Above 0 their distances bend into each other over a band this wide.blend_kind(String, default "polynomial"): Which smooth minimum shapes the fillet, read only whenblendis above 0: "polynomial" reaches the plain result exactly at the edge of the band, "exponential" never quite reaches it, "root" is the smoothest and widest reaching, and "chamfer" cuts the corner off with a flat 45-degree facet.
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 sdf.smooth_min of the two distances (a plain minimum at blend 0). The bounds are the box holding both shapes' bounds, grown by blend; a union with an unbounded shape is unbounded.
Example
local a = g.sdf.sphere({ radius = 0.5, center = vector.create(-0.3, 0, 0) })
local b = g.sdf.box({ size = vector.create(0.6, 0.6, 0.6), center = vector.create(0.3, 0, 0) })
local mesh = g.sdf.mesh({ sdf = g.sdf.union({ a = a, b = b, blend = 0.1 }), resolution = 16 }).geometry