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
Three.js Ray Marching SDF Shapes Gallery
Sphere-traced signed distance fields in a Three.js fullscreen shader, including a box↔sphere morph, torus, octahedron and smooth-union blobs, with soft shadows, ambient occlusion and a step-count heatmap.
Three.js Fractal Mountains (Ray-Marched Terrain)
Infinite procedural mountains ray-marched in a Three.js shader using derivative-damped fBm for eroded ridges, with snow, water, soft sun shadows, aerial perspective and an automatic fly-through.
Three.js Volumetric Clouds (Ray-Marched)
Real-time volumetric clouds in a Three.js shader with fBm density in a cloud slab, self-shadowing light marches, Beer–Lambert transmittance, a powder effect and dual-lobe Henyey–Greenstein scattering.