CPU sphere tracing
2008The same idea as on a GPU, in JavaScript at 128 pixels wide: two balls melting together with smooth min, a torus, soft shadows from distance probes.
t += sdf(ro + rd·t)
1996 to today
Draw two triangles that cover the screen and let every pixel shoot its own ray into a world described by one function: the distance to the nearest surface. It is how a 4 KB intro renders a landscape, and how a generation learned graphics on Shadertoy.
The algorithm
Describe the whole scene as a function that returns, for any point in space, the distance to the closest surface. For each pixel, start at the camera and step along the view ray by exactly that distance: you can never overshoot, and you slow down as you approach a surface. Stop when the distance is tiny. Normals come from the function's gradient; soft shadows and ambient occlusion from a few more distance probes.
The old-hardware trick
Empty space is skipped in big leaps, so a ray needs only tens of steps. Shapes combine with min (union), max (intersection) and a smooth minimum that melts them together; mod() repeats one object infinitely for free. Because every pixel is independent, a GPU runs millions of rays at once, and because the scene is code, not data, it fits in 4 kilobytes.
for each pixel:
rd = camera_ray(pixel) ; t = 0
repeat 100 times:
d = sdf(ro + rd·t) // distance to nearest surface
if d < ε: hit! break
t += d // safe step, never overshoots
n = normalize(∇sdf(p))
colour = light(p, n) · soft_shadow(p, l) · ao(p, n)
sdf(p) = smin(sphere(p), box(p), k)Documented milestones, with a source for each. Famous examples, not claims of who did it first.
John C. Hart · The Visual Computer · Research rendering
The paper formalises distance-based steps that can never penetrate an implicit surface, and derives distance functions and operations on them.
SourceIñigo Quilez · Procedural graphics
Experiments with soft shadows, smooth blending and domain repetition, building on earlier work such as Keenan Crane's and Alex Evans'.
Sourceiq / RGBA · Windows · CPU
First in 4K procedural graphics at Euskal Encounter 16: one function returning the distance to the closest surface, no rasteriser, an executable still image.
SourceIñigo Quilez · NVScene 2008 · GPU pixel shaders
The talk that tied full-screen shaders, 4K intros and distance-field acceleration together, with modelling operators, ambient occlusion and soft shadows.
SourceStill, Loonies and others · PC intros · shaders
In his ‘Behind Elevated’ talk, Quilez calls 2009 a year of ‘AO*Reflection Raymarching’, adoption across the intro scene, documented.
SourceIñigo Quilez & Pol Jeremias · Browser · WebGL
Public shader code with live output: the place where procedural techniques, distance fields above all, are studied, forked and shared.
Sourcealia / Church of the Spinning Cube · macOS · 8K intro
Revision 2021, PC 8K: animated SDFs with real-time path tracing, motion blur and depth of field.
Source4 live versions, from the oldest platform to today: 1 on the CPU, 3 on the GPU. Retro versions run at their original resolution and palette. Demos pause when off screen.
The same idea as on a GPU, in JavaScript at 128 pixels wide: two balls melting together with smooth min, a torus, soft shadows from distance probes.
A sphere, a rounded box, a torus and a blob on a floor, with material IDs, soft shadows and ambient occlusion, the textbook scene, live.
One column and one ball, repeated forever with mod(), lit warm and reflected once. A whole city of pillars from four lines of code.
A 3D fractal with a distance estimate, raymarched like any other SDF. Its power slowly breathes; colour comes from an orbit trap.