subtract.procNode
This package holds more than this page lists. See all of its files in its world.
README.md
sdf.subtract (procNode)
Everything in the first shape that is not in the second: b carved out of a. With blend above 0 the cut 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): The shape being cut into. What is left is made of this one.b(Sdf): The shape being removed. Everything inside it is carved out ofa.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 a and the negated b. The bounds are a's, grown by blend.
Example
local cut = g.sdf.subtract({ a = g.sdf.box({ size = vector.create(1, 1, 1) }), b = g.sdf.sphere({ radius = 0.6 }) })
local mesh = g.sdf.mesh({ sdf = cut, resolution = 16 }).geometry