All effects

t += sdf(ro + rd·t)

Raymarching & SDF.

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.

ResearchPCGPU

How it works

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.

Per frame, in pseudo-code
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)

Timeline

Documented milestones, with a source for each. Famous examples, not claims of who did it first.

  1. 1996Research

    Sphere tracing

    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.

    Source
  2. 2007Research

    Art-directed distance fields

    Iñ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'.

    Source
  3. 2008PC

    Slisesix

    iq / 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.

    Source
  4. 2008GPU

    Rendering worlds with two triangles

    Iñ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.

    Source
  5. 2009GPU

    The year of raymarching

    Still, 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.

    Source
  6. 2013GPU

    Shadertoy

    Iñ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.

    Source
  7. 2021GPU

    Electrocat

    alia / 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.

    Source

Over time

4 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.

PC · CPU · like Slisesix

CPU sphere tracing

2008

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.

PCCPUSDFsmooth min
Detail page
GPU · GLSL

Two triangles

2008

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.

GPUGPUsoft shadowsAO
Detail page
GPU · 4K-intro style

Infinite repetition

2009

One column and one ball, repeated forever with mod(), lit warm and reflected once. A whole city of pillars from four lines of code.

GPUGPUdomain repetitionreflection
Detail page
GPU · fractal

Mandelbulb

2009

A 3D fractal with a distance estimate, raymarched like any other SDF. Its power slowly breathes; colour comes from an orbit trap.

GPUGPUfractaldistance estimator
Detail page