← All Projects
Ray Marcher
A WebGL fragment shader that renders 3D scenes using ray marching. Real-time constructive solid geometry, soft shadows, and ambient occlusion.
WebGLGLSLRayMarching
What Is Ray Marching?
Unlike traditional rasterization, ray marching traces rays through a signed distance field (SDF) to find surface intersections. This enables rendering complex shapes like fractals, blobs, and CSG operations that would be difficult with polygons.
Features
- Constructive solid geometry — union, subtraction, and intersection of shapes
- Soft shadows via secondary ray marching toward light sources
- Ambient occlusion for contact shadows
- Animated blend between shape configurations
The Shader
The entire renderer fits in a single fragment shader. The SDF defines the scene geometry; the ray march loop steps along each ray until it hits a surface or exceeds the max distance.