Three.js Ray Marching Examples

Ray marching renders a scene without any triangles. A fragment shader steps a ray from the camera through space for every pixel, using signed distance functions (SDFs) to know how far it can safely move until it hits a surface.

These demos use the technique for smooth-blended SDF shapes, infinite fractal mountain terrain and volumetric clouds that are lit as light scatters through them. Each page explains the marching loop, how normals and shadows are computed from the distance field, and how to keep the step count low enough for real-time frame rates.

Most viewed in ray marching

All ray marching demos

3 Demos