Sculpting SDF shapes: blends, symmetry, and domain repetition
Learning objectives
- learner can blend SDFs with smooth-minimum and control the join radius
- learner can distort and displace SDF space, including ellipsoid scaling
- learner can tile and mirror shapes with domain repetition, symmetry-abs, and per-cell IDs
Capstone — one whole task that evidences the objectives
Sculpt an organic SDF form by smooth-blending primitives, mirroring with abs-symmetry, displacing the input coordinate, and tiling the result across a repeated domain with per-cell variation.
Prerequisite modules
This module is where a raymarched scene stops looking like floating geometry-demo spheres and starts looking like something you would put on screen at a show. In a live-coding visual set — a fragment shader hot-reloading behind the audio rig — you rarely have time to model anything. Instead you sculpt: a couple of primitives, merged, mirrored, warped, and multiplied until one distance function reads as a creature, a colony, a landscape. Everything here is a transformation of either the distance value or the input coordinate, which is why it stays fast enough to run per-pixel at 60fps.
The arc starts supported. First exercise: take two spheres from your first-SDF-scene module and join them with the smooth minimum, sweeping the blend radius k live to feel how the crease rounds into an organic merge. Then swap a sphere for an ellipsoid via space scaling, and add a feature on one side only — an eye, a fin — and mirror it for free with the abs-symmetry trick, watching for the classic half-shape-on-the-axis pitfall. Next, bend the form itself by perturbing p before evaluation (the displacement atom is your JIT pointer here, including its warning about breaking the distance bound). Finally, wrap the whole sculpt in domain repetition and use the floor-derived cell ID to vary each copy, so the tiled field reads alive rather than synthetic.
The capstone is the same task unsupported: one organic form, blended, mirrored, displaced, tiled with per-cell variation. Each required atom gates one of those verbs — skip any and the capstone visibly fails. The supporting atoms enrich: triplet-based rotations give cheap exact tilts to break symmetry tastefully, and scale-to-zero discard is a neighbouring instancing idea from the mesh world that contextualises why repetition-by-coordinate-folding is such a win.
Runnable examples
Generated from the context/ instrument corpus by concept (redistributable idioms only). Do not edit — regenerate with gen-module-examples.mjs.
tiling-repeat
osc(10).repeat(3, 3).out()
hydra-0008 · CC0-1.0
tile [4,4] (circle 0 0.3) >> add
punctual-0020 · CC0-1.0
radial-symmetry
osc(10).kaleid(5).out()
hydra-0010 · CC0-1.0
// sandbox
osc(10, 0.05, 1.3).kaleid(8).out()
// sandbox
p5live-0037 · CC0-1.0
sdf-shape
circle [0,0] 0.4 >> add
punctual-0018 · CC0-1.0
float d = length(uv) - r;
glsl-0003 · public-domain
mirror
uv = abs(uv);
glsl-0010 · public-domain
osc(10).kaleid(2).out()
hydra-0011 · CC0-1.0
boolean-sdf
float u = min(a, b); float s = max(a, -b);
glsl-0006 · public-domain
Atoms in this module
Required — these gate the capstone
Supporting — enrichment, not gating
Part of curricula
- Shader Artist — real-time GPU craft to a demoscene-grade visual — Raymarching and sculpting SDF worlds required
Unlocks — modules that require this one