Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

sdf.smooth_min (procNode)

The minimum of two distances, bent into a fillet over a band k wide; the operation sdf.union is built from. It takes distances (Float fields or numbers), such as the field of two shapes, and answers a distance; the caller states the bounds of the result.

Inputs

  • a (Field<Float> | Float): One of the two distances.
  • b (Field<Float> | Float): The other distance.
  • k (Float, default 0.0): How wide the fillet is, in the shapes' own units. At 0 the result is the plain minimum, a hard crease; above 0 the two distances bend into each other over a band this wide.
  • kind (String, default "polynomial"): Which smooth curve shapes the fillet, read only when k is above 0: "polynomial" (quadratic) 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

  • value (Field<Float> | Float): the blended distance.

Example

local a = g.sdf.sphere({ radius = 0.5, center = vector.create(-0.3, 0, 0) })
local b = g.sdf.sphere({ radius = 0.5, center = vector.create(0.3, 0, 0) })
local blended = g.sdf.smooth_min({ a = a.field, b = b.field, k = 0.25 })
local shape = { field = blended, bounds = { min = vector.create(-1, -0.75, -0.75), max = vector.create(1, 0.75, 0.75) } }
local mesh = g.sdf.mesh({ sdf = shape, resolution = 16 }).geometry