Game dev
Saved & recent

Ray marching

Related terms: sphere tracing, Shadertoy

Drawing a scene by walking along a ray in steps until it hits something. There are no triangles. The scene is a signed distance field, and the distance value says how far the ray can safely jump without passing through a surface.

The whole renderer fits in one fragment shader, run once per pixel. Games use it for clouds, fog and volumetric light. Demos use it to draw entire worlds with no meshes at all.

Further reading
Tektite Studio: Ray Marching, Signed Distance Fields and Sphere Tracing
safe step ray origin surface hit scene surface
Each dashed circle is the safe distance at that step. The ray stops within one unit of the blue surface.

View in the full Game dev collection