home/ modules/ advanced-sdf-geometry-and-curves

Advanced SDF geometry: curves, implicit forms, and material channels

  • learner can derive SDFs from implicit equations and build quadratic Bezier curve fields
  • learner can reason about exact vs approximate SDFs and use signed backtracking
  • learner can extend map() with material IDs and vec4 auxiliary channels and map spherical UVs onto surfaces

Build an SDF scene featuring a Bezier-curve glyph derived from an implicit equation, returning per-object material IDs plus vec4 auxiliary UV/occlusion channels, and texture a sphere with spherical UVs.

This module is where your raymarched visuals stop looking like demo-scene sphere soup and start carrying identity. In a live set, the shapes on screen are your typography: a logo glyph, a signature curve, a textured planet that recurs across the night. The capstone is exactly that whole task — a Bezier-curve glyph grown from an implicit equation, wired into a scene that reports material IDs and auxiliary channels so the shading pass can texture a sphere with proper spherical UVs, all running at projector framerate.

The arc starts supported: take a known implicit curve and convert it to a distance field using the deriving-SDFs-from-implicit-equations procedure, then swap in IQ’s three-control-point quadratic Bezier field and animate its control points — these two are your part-task drills, because mid-performance you will sketch curves faster than you can look them up. Next you confront why the glyph flickers or crawls: the exact-versus-approximate distinction explains your step sizes, and abs()-based signed backtracking is the JIT fix when a displaced field overshoots. Finally you plumb the data path — extending map() to a vec4 so UVs and occlusion travel with the winning material, then mapping latitude/longitude onto the sphere.

The required atoms gate the capstone directly: without the implicit-equation and Bezier techniques there is no glyph; without exactness reasoning and backtracking it won’t render stably; without vec4 channels and spherical UVs there is nothing to texture. Supporting atoms deepen the craft — polynomial smooth-min rigidity for when you later blend glyphs, ray differentials for antialiased edges, and Perlin noise as a UV-free alternative texture source.

Runnable examples

Generated from the context/ instrument corpus by concept (redistributable idioms only). Do not edit — regenerate with gen-module-examples.mjs.

sdf-shape

circle [0,0] 0.4 >> add

punctual-0018 · CC0-1.0

float d = length(uv) - r;

glsl-0003 · public-domain

noise-field

noise(4, 0.1).out()

hydra-0002 · CC0-1.0

float h21(vec2 p){return fract(sin(dot(p,vec2(12.9898,78.233)))*43758.5453);}

glsl-0013 · public-domain

raymarch-sdf

vec3 nrm(vec3 p){vec2 e=vec2(.001,0);return normalize(vec3(map(p+e.xyy)-map(p-e.xyy),map(p+e.yxy)-map(p-e.yxy),map(p+e.yyx)-map(p-e.yyx)));}

glsl-0033 · public-domain

Atoms in this module

Required — these gate the capstone

An SDF can be derived from any implicit curve equation by setting the LHS equal to d
Procedure L3 Craft G
A quadratic Bezier SDF takes three control points and returns distance to the curve
Concept L3 Craft G
Exact SDFs give the true Euclidean distance; approximate SDFs are safe lower bounds but force smaller marching steps
Concept L3 Craft G
Adding abs() to a displaced SDF allows the raymarcher to backtrack when it overshoots a surface
Concept L3 Craft G
Extending map() to return a vec4 provides auxiliary channels for UV coordinates, occlusion, and per-material signals
Concept L3 Craft G
Spherical UV coordinates map latitude/longitude angles to texture image coordinates for sphere texturing
Procedure L3 Craft G

Supporting — enrichment, not gating

Polynomial smooth-min functions preserve SDF shape outside the blend zone; exponential versions distort the whole field
Concept L3 Craft G
Ray differentials estimate how much of a pixel's footprint overlaps SDF geometry to produce smooth antialiased edges
Concept L3 Craft G
Perlin noise is a repeatable pseudo-random function of 3D position used for procedural textures
Concept L3 Craft G