Builtin Library
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 insidesdf.box— An axis-aligned box as a signed distance field, with sharp edges and cornerssdf.rounded_box— A box whose edges and corners are rounded toradiussdf.torus— A torus — a ring of radiusmajor_radiuswhose tube isminor_radiusthick — lying in the plane perpendicular toaxissdf.capsule— A capsule — a cylinder ofradiuscapped with a hemisphere at each end — running alongaxissdf.cylinder— A cylinder ofradiusandheightrunning alongaxis, with flat ends and a sharp rimsdf.cone— A cone standing on a flat base ofradius, tapering to a pointheightalongaxissdf.plane— A half-space: everything on the back side of an infinite plane is insidesdf.union— Both shapes, as one solidsdf.subtract— Everything inathat is not also inb—bcarves a cavity out ofasdf.intersect— Only what is inside BOTH shapes — the overlapsdf.transform— Move, turn and resize a shapesdf.twist— Twist the space around an axis: a point is turned aboutaxisbyanglefor every unit it stands along that axis, so a straight column becomes a helix and a box becomes a twisted prismsdf.bend— Bend the space: a point is turned aboutaxisbyanglefor every unit it stands alongalong, so a straight bar curls into an arcsdf.taper— Taper the space along an axis: the cross-section perpendicular toaxisis scaled bystart_scaleat thefromend andend_scaleat thetoend, 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 shapesdf.shell— Hollow a solid out into a shell ofthickness, centred on its original surfacesdf.mirror— Mirror the space across the planes throughcenter, so whatever was built on the positive side of each named axis appears on both sidessdf.repeat— Repeat a shape on a lattice by folding the point being evaluated back into one cell of itsdf.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 skinsdf.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 drawgeometry.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 primitivesdf.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