Builtin Library
README.md
sdf.intersect (procNode)
Only what is inside both shapes: the maximum of their distances. With blend above 0 the seam around the overlap is filleted. 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. Intersection 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_max of the two distances (a plain maximum at blend 0). The bounds are the overlap of the two shapes' bounds, grown by blend; an infinite bound gives way to a finite one, so intersecting with sdf.plane keeps the other shape's bounds.
Example
local shape = g.sdf.intersect({ a = g.sdf.sphere({ radius = 1 }), b = g.sdf.plane({ normal = vector.create(0, 1, 0) }) })
local mesh = g.sdf.mesh({ sdf = shape, resolution = 16 }).geometry