home/ atoms/ sdf-scene-composition-min

The minimum of multiple SDFs combines them into a single scene that ray marchers can query

When a scene contains multiple objects (a sphere, a floor plane, a creature body), the map() function evaluates each SDF and returns the minimum. A raymarcher calling map() gets the distance to the closest surface regardless of which object it belongs to. This min-union operation is the core compositing primitive in SDF rendering: adding a new object is as simple as inserting a min() call. The object that wins the minimum is the visible one; the others are hidden behind it or further away.

Examples

float map(vec3 p){ float sphere=length(p)-0.25; float floor=p.y+0.1; return min(sphere,floor); } — both objects exist; the closer one sets the step size.

Assessment

Explain why adding a third object (e.g. a box SDF) to a scene requires only a new min() call in map(), without changing the raymarcher loop.

“minimum of all the distances. So we are evaluating the 1 for the sphere, the 2 for the plane, and then whichever is smallest. And that's how far is the closest thing in the scene”
corpus · inigo-quilez-live-coding-happy-jumping-video · chunk 4