Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit192c685f66

README.md

sdf

Signed distance fields: shapes as distance, combined smoothly, and carried across to and from geometry.

The definitions live in proc.ops.sdf; this pack is what puts them in the op registry, so procgen.searchNodes("", { pack = "sdf" }) lists the family and procgen.describeNode("op.<id>") describes any one of them.

Ops

  • sdf.sphere — A sphere as a signed distance field — the distance from any point to its surface, negative inside
  • sdf.box — An axis-aligned box as a signed distance field, with sharp edges and corners
  • sdf.rounded_box — A box whose edges and corners are rounded to radius
  • sdf.torus — A torus — a ring of radius major_radius whose tube is minor_radius thick — lying in the plane perpendicular to axis
  • sdf.capsule — A capsule — a cylinder of radius capped with a hemisphere at each end — running along axis
  • sdf.cylinder — A cylinder of radius and height running along axis, with flat ends and a sharp rim
  • sdf.cone — A cone standing on a flat base of radius, tapering to a point height along axis
  • sdf.plane — A half-space: everything on the back side of an infinite plane is inside
  • sdf.union — Both shapes, as one solid
  • sdf.subtract — Everything in a that is not also in b — b carves a cavity out of a
  • sdf.intersect — Only what is inside BOTH shapes — the overlap
  • sdf.transform — Move, turn and resize a shape
  • sdf.twist — Twist the space around an axis: a point is turned about axis by angle for every unit it stands along that axis, so a straight column becomes a helix and a box becomes a twisted prism
  • sdf.bend — Bend the space: a point is turned about axis by angle for every unit it stands along along, so a straight bar curls into an arc
  • sdf.taper — Taper the space along an axis: the cross-section perpendicular to axis is scaled by start_scale at the from end and end_scale at the to end, and linearly between them — a cylinder becomes a truncated cone,...
  • sdf.elongate — Stretch a shape by pulling it apart along each axis and filling the gap with a straight extrusion of its middle — a sphere becomes a capsule, a rounded box becomes a longer rounded box, and the ends keep their origi...
  • sdf.round — Offset the surface by a constant — the operator that rounds a shape
  • sdf.shell — Hollow a solid out into a shell of thickness, centred on its original surface
  • sdf.mirror — Mirror the space across the planes through center, so whatever was built on the positive side of each named axis appears on both sides
  • sdf.repeat — Repeat a shape on a lattice by folding the point being evaluated back into one cell of it
  • sdf.position — The point currently being evaluated, as a Field<Vec3>
  • sdf.displace — Push the surface in and out by whatever a field says at each point — the op that turns a smooth primitive into rock, bark or a wrinkled skin
  • sdf.mesh — Contour an Sdf into a CLOSED triangle mesh — the step that turns a field back into geometry every other part of the engine can draw
  • geometry.to_sdf — Read an existing mesh back into a field, so a modelled or imported shape can be smooth-unioned, shelled, repeated or displaced like any primitive
  • sdf.from_grid — Read a channel of a Grid as a signed distance field: the value at any point is blended from the eight cell centres around it, and outside the outermost centres it is the edge's value plus how far the point stands from...
  • sdf.sample — Read an Sdf at every element of a domain, as a Field<Float> — the bridge from a field of space to the per-element world scattering and filtering live in