Real-time Water Caustics
Approximate the bright, moving light patterns on a pool floor by refracting light through the water surface and splatting where each ray lands, or by scattering and tracing a cheap procedural pattern.
Also known as image-space caustics, caustic mapping
In the family Atmosphere, water & volumes, water
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Official add-on | examples/webgpu_caustics.html docs Official example, not a setting. |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | None found | |
| Unity | Built in | Water Surface > Caustics docs HDRP only. |
| Unreal 5.7 | None found | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Render the water surface from the light's point of view as a normal map and refract the light direction at each texel (Snell's law). Each refracted ray is intersected with the receiving geometry, either by marching a depth/height texture of the floor, or analytically for a flat floor. Rays are splatted as small additive quads or points into a caustic texture; where rays converge the sum gets brighter, and the texture is then projected onto the scene. A cheaper version, popular in WebGL demos, compares the area of each refracted cell before and after refraction using screen-space derivatives of the refracted position, which gives intensity as the ratio of areas and avoids splatting. Temporal blur and a small blur kernel suppress noise. The caustic texture is multiplied into the lighting of floors, hulls and shadowed regions.
When to choose it
Reach for it when
- pool floor lacks dancing light patterns
- underwater scenes need moving bright ripples
- need cheap plausible caustics for water
- light through waves should focus on seabed
Choose it for pools, shallow seas and fountains when you can trade accuracy for a plausible, animated light pattern at low cost.
Prefer procedural approximations in the material (e.g. layered Voronoi noise) when the surface is not simulated and only the visual matters. Prefer path tracing with photon mapping offline for exact results. Use alongside FFT Ocean (Tessendorf), Gerstner (Trochoidal) Waves or Shallow Water Equations (Height-field Water) as the source of surface normals.
Field marks
- Noisy, speckled caustics when splat density is too low
- Missing caustics shadowing: objects in the water do not occlude the caustic light unless added
- Wrong pattern focus depth if the floor distance used is a constant and the real floor is deep or sloped
- Flicker as the surface moves because caustic intensity is computed per frame without temporal filtering
- Only the first refraction is handled: reflective caustics and caustics from submerged objects are missing
Presets
Analytic refraction caustics on a pool floor from an animated wave field
{
"DEPTH": 2,
"AMP": 0.05
}Show GLSL (36 lines)
// Analytic water caustics on a pool floor. Rays refract through an animated wave height field
// (Snell, eta=1/1.33); the floor point P is mapped back to its surface source by fixed-point iteration, and
// intensity = 1 / |det(d landing / d surface)|: focusing where neighbouring rays converge.
const float DEPTH = 2.0;
const float AMP = 0.05;
vec2 slope(vec2 p) {
vec2 g = vec2(0.0);
g += AMP * 6.0 * cos(dot(vec2(0.8, 0.6), p) * 6.0 + iTime * 1.3) * vec2(0.8, 0.6);
g += AMP * 8.0 * cos(dot(vec2(-0.5, 0.86), p) * 8.0 - iTime * 1.7) * vec2(-0.5, 0.86);
g += AMP * 11.0 * cos(dot(vec2(0.2, -0.98), p) * 11.0 + iTime * 2.1) * vec2(0.2, -0.98);
g += AMP * 14.0 * 0.6 * cos(dot(vec2(-0.9, -0.43), p) * 14.0 - iTime * 2.6) * vec2(-0.9, -0.43);
return g;
}
vec2 land(vec2 p) {
vec2 g = slope(p);
vec3 d = refract(vec3(0.0, -1.0, 0.0), normalize(vec3(-g.x, 1.0, -g.y)), 1.0 / 1.33);
return p + d.xz / (-d.y) * DEPTH;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
vec2 P = uv * 3.0;
vec2 x = P;
for (int i = 0; i < 4; i++) x = P - (land(x) - x);
float e = 0.004;
vec2 fx = (land(x + vec2(e, 0.0)) - land(x - vec2(e, 0.0))) / (2.0 * e);
vec2 fy = (land(x + vec2(0.0, e)) - land(x - vec2(0.0, e))) / (2.0 * e);
float I = clamp(1.0 / max(abs(fx.x * fy.y - fx.y * fy.x), 0.12), 0.0, 6.0);
vec2 tile = fract(P * 0.8);
vec3 floorc = mix(vec3(0.08, 0.3, 0.38), vec3(0.1, 0.38, 0.45), step(0.5, fract(floor(P.x * 0.8) * 0.5 + floor(P.y * 0.8) * 0.5) * 2.0));
if (min(tile.x, tile.y) < 0.03) floorc *= 0.6;
vec3 col = floorc * (0.25 + 0.55 * I) + vec3(0.6, 0.95, 1.0) * pow(I / 6.0, 2.0) * 1.5;
col = col / (1.0 + 0.5 * col);
fragColor = vec4(pow(col, vec3(1.0 / 2.2)), 1.0);
}
Attribution: written for this index
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| water-caustics-realtime-specimen | Tesla T4 1920x1080 | 9.32× baseline (moderate) · 0.306 ms / 0.327 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| water-caustics-realtime-specimen | NVIDIA L4 1920x1080 | 7.96× baseline (moderate) · 0.127 ms / 0.128 ms · 2.4× faster on L4 | opengl-timer-query · Cross-architecture validation |
| water-caustics-realtime-specimen | NVIDIA A100-SXM4-40GB 1920x1080 | 5.26× baseline (light) · 0.152 ms / 0.152 ms · 2.0× faster on A100 | opengl-timer-query · Cross-architecture validation |
Crosses
- Bathymetry-refracted coastal ocean with shore caustics: Deep-water spectral swells that physically bend parallel to curving coastlines, steepen as water shallows, and project crisp dancing caustics onto the submerged sand. Solving the eikonal phase field from seabed depth bridges open-ocean FFT synthesis with realistic nearshore breaking and refraction.
- Meshlet kelp forests through underwater PSF scattering: Dense swaying kelp forests rendered at millions of triangles without CPU draw-call overhead, then veiled in physically grounded underwater forward scattering. Caustic shafts light the blades while a depth-varying small-angle point-spread filter softens distant fronds into authentic oceanic haze instead of flat exponential fog.
- Shallow Water Equations (Height-field Water): Height field normals feed the caustic refraction pass in an interactive pool.
Sources
- primaryChris Wyman, Scott Davis (2006). Interactive image-space techniques for approximating caustics. Proceedings of the 2006 symposium on Interactive 3D graphics and games - SI3D '06.Verified via crossref · 2026-11-29doi:10.1145/1111411.1111439
- primaryMusawir A. Shah, Jaakko Konttinen, Sumanta Pattanaik (2007). Caustics Mapping: An Image-Space Technique for Real-Time Caustics. IEEE Transactions on Visualization and Computer Graphics.Verified via crossref · 2026-11-29doi:10.1109/tvcg.2007.32
- implementationevanw (2015). evanw/webgl-water. WebGL Water DemoGitHub API · no license declared · 2026-11-29
- implementationGökay Aydoğan (2026). gokayfem/glsl-studies. 454 procedural graphics studies in GLSL ES 3.00 for WebGL2, from woven cloth and animal fur to glacial terrain and atmospheric optics. Each study includes shader source and a rendered preview.GitHub API · license MIT · 2026-11-30