Raymarching & SDF

Version 2 of 4

Two triangles.

GPU · GLSL · 2008

This version

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.

How this version works

At a render scale of 0.6, the fragment shader orbits a camera around a bouncing sphere, rotating rounded box, tilted torus and smoothly blended pair of small spheres. Its scene function returns both distance and a material identifier, assigning separate colours to the objects and a chequer pattern to the floor. Each primary ray takes up to 100 steps, with a hit threshold that grows with distance. Finite-difference normals, a 40-step shadow loop and five ambient-occlusion probes supply the lighting, supplemented by specular highlights, distance-squared fog and gamma adjustment.

The trick in this version

The full-screen shader computes the scene independently for each fragment instead of rasterising object meshes. Returning a material identifier alongside the distance lets the same scene queries support both intersection finding and surface colouring.

Historical context · GPU

  1. 2008 · Iñigo Quilez · NVScene 2008

    Rendering worlds with two triangles

    The talk that tied full-screen shaders, 4K intros and distance-field acceleration together, with modelling operators, ambient occlusion and soft shadows.

  2. 2009 · Still, Loonies and others

    The year of raymarching

    In his ‘Behind Elevated’ talk, Quilez calls 2009 a year of ‘AO*Reflection Raymarching’, adoption across the intro scene, documented.

  3. 2013 · Iñigo Quilez & Pol Jeremias

    Shadertoy

    Public shader code with live output: the place where procedural techniques, distance fields above all, are studied, forked and shared.

Platform
GPU · GLSL
Era
GPU
Rendered on
GPU
Tags
soft shadows · AO
Sources
Rendering worlds with two triangles (2008)The year of raymarching (2009)Shadertoy (2013)