Raymarching a distance field

A 2D slice through an SDF scene. Every circle is one step, and its radius is the distance field at that point.

outside (d > 0) inside (d < 0) the surface (d = 0) step circle = safe distance hit miss

Drag the white dot to move the ray origin, the small ring to aim it. The thin strip underneath is the 1-D image a camera at that origin would render.

What to notice. The circles are tangent: each step lands exactly on the edge of the previous circle, because the field promised nothing was nearer than that. Aim the ray so it grazes a shape and the steps crawl — that is why silhouettes cost the most. Change scene and watch the boolean appear in the bands themselves, not just in the outline: subtraction really does put a negative region back outside. Then push step × above 1 on the thin-walls scene and the ray punches straight through solid geometry — exactly the artefact a non-exact distance field gives you for free.

← all demos