Skip to content

The swept horn grammar

Procedural geometry in this toolbox starts from the horn: a cross-section (profile) swept along a curve and warped by an ordered stack of transforms — bend, twist, scale — then optionally instanced into towers and whorls by the structural ops stack and branch. It is a clean re-derivation of the FormGrow horn grammar from the long-running Todd–Latham collaboration, rebuilt here as a lazy, typed geometry expression-IR (see decision record ADR-0010).

The defining property is that a horn is pointwise closed-form:

eval(s, θ) → (position, normal)\mathrm{eval}(s,\ \theta)\ \rightarrow\ (\text{position},\ \text{normal})

for a sweep coordinate s∈[0,1]s \in [0,1] (base → tip) and a spoke coordinate θ∈[0,2π)\theta \in [0,2\pi) (around the profile). There is no marching or recurrence along the sweep, so the same expression is compiled two ways that agree by construction: a CPU golden (s, θ) loop, and a per-vertex WGSL kernel generated from the same IR. A parity test pins them together to within 1e-4.

The grammar’s parameters are ordinary numbers, so they breed. This demo is a Todd–Latham Mutator grid: each of the nine cells is a horn, you select parents and breed a new generation, and the grid eases between genotypes with the toolbox’s own one-pole trait-damping.

▶ Open the horn Mutator — a full-page interactive demo (opens in this tab; use your browser’s back button to return).

  • Drag anywhere to orbit all nine cells; scroll to zoom.
  • Click a cell to select it as the parent; ⇧-click to add more parents.
  • Breed produces a generation of mutated offspring around the selected elite; Randomize scatters fresh genotypes.
  • Open the folded parameters panel to edit a specimen’s genes directly and read the equivalent horn(…) chain.