Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

sdf.smooth_max (procNode)

The maximum of two distances, bent into a fillet over a band k wide: sdf.smooth_min of the negated distances, negated. The operation sdf.intersect and sdf.subtract are built from. It takes distances (Float fields or numbers), such as the field of two shapes, and answers a distance.

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 maximum, 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.2, 0, 0) })
local b = g.sdf.sphere({ radius = 0.5, center = vector.create(0.2, 0, 0) })
local lens = g.sdf.smooth_max({ a = a.field, b = b.field, k = 0.1 })
local shape = { field = lens, bounds = { min = vector.create(-0.5, -0.5, -0.5), max = vector.create(0.5, 0.5, 0.5) } }
local mesh = g.sdf.mesh({ sdf = shape, resolution = 16 }).geometry