home/ modules/ sculpting-and-transforming-sdf-shapes

Sculpting SDF shapes: blends, symmetry, and domain repetition

  • 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

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.

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

The smooth minimum (smin) blends two SDFs with a controllable rounded join instead of a sharp union
Concept L2 First instrument G
Displacing an SDF's input coordinate before evaluation deforms the shape by any function
Concept L2 First instrument G
An ellipsoid SDF is computed by scaling space to transform the ellipsoid into a unit sphere
Concept L2 First instrument G
Wrapping the input coordinate into a periodic cell tiles one SDF into infinite copies at near-zero cost
Concept L2 First instrument GJ
The floor of the repeated domain gives a unique integer ID per tiled instance for per-cell variation
Concept L2 First instrument G
Taking the absolute value of one coordinate in an SDF replicates geometry on both sides of a mirror plane
Concept L2 First instrument G
Folding or repeating UV coordinates multiplies SDF shapes without extra draw calls
Concept L2 First instrument G

Supporting — enrichment, not gating

Pythagorean integer triplets provide exact normalized rotation matrices without trigonometry
Concept L2 First instrument G
Multiplying vertex positions by 0 collapses geometry to a single point, which the GPU silently discards — an efficient way to hide inactive instances
Concept L2 First instrument G
Symmetry (reflection, radial, tiling) turns a small motif into a full frame at minimal cost
Principle L2 First instrument LGH
Geometric visuals are built by combining one SDF shape with boolean operations, then imposing symmetry, then composing the frame
Procedure L2 First instrument HG