{
 "id": "water-caustics-realtime",
 "title": "Real-time Water Caustics",
 "aliases": [
  "image-space caustics",
  "caustic mapping"
 ],
 "domain": "volumes",
 "subdomain": "water",
 "stage": "volume",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "mobile-gpu"
 ],
 "year_introduced": 2006,
 "inputs": [
  "normals",
  "heightfield",
  "depth"
 ],
 "outputs": [
  "texture",
  "irradiance-probes"
 ],
 "style": "both",
 "dynamic": "dynamic",
 "summary": "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.",
 "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_use": "Choose it for pools, shallow seas and fountains when you can trade accuracy for a plausible, animated light pattern at low cost.\n\nPrefer 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`, `gerstner-waves` or `shallow-water-equations` as the source of surface normals.",
 "cost": {
  "class": "medium",
  "notes": "Splatting costs rise with surface resolution and overdraw; derivative-based methods are cheap."
 },
 "failure_modes": [
  "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"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/1111411.1111439",
   "type": "paper",
   "title": "Interactive image-space techniques for approximating caustics",
   "authors": [
    "Chris Wyman",
    "Scott Davis"
   ],
   "year": 2006,
   "venue": "Proceedings of the 2006 symposium on Interactive 3D graphics and games  - SI3D '06",
   "url": "https://doi.org/10.1145/1111411.1111439",
   "ids": {
    "doi": "10.1145/1111411.1111439"
   },
   "license": null,
   "extra": {
    "csl_type": "proceedings-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1111411.1111439",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1111411.1111439",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1111411.1111439",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1111411.1111439",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1111411.1111439",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "wyman2006interactive"
  },
  {
   "role": "primary",
   "key": "doi:10.1109/tvcg.2007.32",
   "type": "paper",
   "title": "Caustics Mapping: An Image-Space Technique for Real-Time Caustics",
   "authors": [
    "Musawir A. Shah",
    "Jaakko Konttinen",
    "Sumanta Pattanaik"
   ],
   "year": 2007,
   "venue": "IEEE Transactions on Visualization and Computer Graphics",
   "url": "https://doi.org/10.1109/tvcg.2007.32",
   "ids": {
    "doi": "10.1109/tvcg.2007.32"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1109/tvcg.2007.32",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1109/tvcg.2007.32",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1109/tvcg.2007.32",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1109/tvcg.2007.32",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1109/tvcg.2007.32",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "shah2007caustics"
  },
  {
   "role": "implementation",
   "key": "gh:evanw/webgl-water",
   "type": "code",
   "title": "evanw/webgl-water",
   "description": "WebGL Water Demo",
   "authors": [
    "evanw"
   ],
   "year": 2015,
   "venue": "GitHub",
   "url": "https://github.com/evanw/webgl-water",
   "ids": {
    "repo": "evanw/webgl-water"
   },
   "license": null,
   "extra": {
    "stars": 1287,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2022-12-31T11:43:00Z",
    "language": "JavaScript",
    "homepage": null,
    "license_name": null
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/evanw/webgl-water",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/evanw/webgl-water",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/evanw/webgl-water",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/evanw/webgl-water",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/evanw/webgl-water",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/evanw/webgl-water",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "evanw2015evanw"
  },
  {
   "role": "implementation",
   "key": "gh:gokayfem/glsl-studies",
   "ids": {
    "repo": "gokayfem/glsl-studies"
   },
   "type": "code",
   "title": "gokayfem/glsl-studies",
   "authors": [
    "Gökay Aydoğan"
   ],
   "year": 2026,
   "venue": "GitHub",
   "url": "https://github.com/gokayfem/glsl-studies",
   "license": "MIT",
   "description": "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.",
   "extra": {
    "stars": 924,
    "stars_checked": "2026-11-30",
    "language": "GLSL",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-11-30T13:13:54Z",
    "homepage": null,
    "license_name": "MIT License"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/gokayfem/glsl-studies",
     "checked_at": "2026-11-30T21:49:39.376Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/gokayfem/glsl-studies",
     "checked_at": "2026-11-30T21:49:39.376Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/gokayfem/glsl-studies",
     "checked_at": "2026-11-30T21:49:39.376Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/gokayfem/glsl-studies",
     "checked_at": "2026-11-30T21:49:39.376Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/gokayfem/glsl-studies",
     "checked_at": "2026-11-30T21:49:39.376Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/gokayfem/glsl-studies",
     "checked_at": "2026-11-30T21:49:39.376Z"
    }
   },
   "status": "verified",
   "title_sim": null,
   "checked_at": "2026-11-30T21:49:39.376Z",
   "__bib": "aydoan2026gokayfem"
  }
 ],
 "presets": [
  {
   "id": "water-caustics-realtime-specimen",
   "title": "Analytic refraction caustics on a pool floor from an animated wave field",
   "runtime": "glsl-fragment",
   "params": {
    "DEPTH": 2,
    "AMP": 0.05
   },
   "code": "// Analytic water caustics on a pool floor. Rays refract through an animated wave height field\n// (Snell, eta=1/1.33); the floor point P is mapped back to its surface source by fixed-point iteration, and\n// intensity = 1 / |det(d landing / d surface)|: focusing where neighbouring rays converge.\nconst float DEPTH = 2.0;\nconst float AMP = 0.05;\n\nvec2 slope(vec2 p) {\n  vec2 g = vec2(0.0);\n  g += AMP * 6.0 * cos(dot(vec2(0.8, 0.6), p) * 6.0 + iTime * 1.3) * vec2(0.8, 0.6);\n  g += AMP * 8.0 * cos(dot(vec2(-0.5, 0.86), p) * 8.0 - iTime * 1.7) * vec2(-0.5, 0.86);\n  g += AMP * 11.0 * cos(dot(vec2(0.2, -0.98), p) * 11.0 + iTime * 2.1) * vec2(0.2, -0.98);\n  g += AMP * 14.0 * 0.6 * cos(dot(vec2(-0.9, -0.43), p) * 14.0 - iTime * 2.6) * vec2(-0.9, -0.43);\n  return g;\n}\nvec2 land(vec2 p) {\n  vec2 g = slope(p);\n  vec3 d = refract(vec3(0.0, -1.0, 0.0), normalize(vec3(-g.x, 1.0, -g.y)), 1.0 / 1.33);\n  return p + d.xz / (-d.y) * DEPTH;\n}\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  vec2 P = uv * 3.0;\n  vec2 x = P;\n  for (int i = 0; i < 4; i++) x = P - (land(x) - x);\n  float e = 0.004;\n  vec2 fx = (land(x + vec2(e, 0.0)) - land(x - vec2(e, 0.0))) / (2.0 * e);\n  vec2 fy = (land(x + vec2(0.0, e)) - land(x - vec2(0.0, e))) / (2.0 * e);\n  float I = clamp(1.0 / max(abs(fx.x * fy.y - fx.y * fy.x), 0.12), 0.0, 6.0);\n  vec2 tile = fract(P * 0.8);\n  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));\n  if (min(tile.x, tile.y) < 0.03) floorc *= 0.6;\n  vec3 col = floorc * (0.25 + 0.55 * I) + vec3(0.6, 0.95, 1.0) * pow(I / 6.0, 2.0) * 1.5;\n  col = col / (1.0 + 0.5 * col);\n  fragColor = vec4(pow(col, vec3(1.0 / 2.2)), 1.0);\n}\n",
   "basis": "original",
   "license_note": "written for this index",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-29",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "water-caustics-realtime",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-29T15:51:50.471Z",
     "renderer": "Chromium 145.0.7632.6 headless, WebGL2 via ANGLE/SwiftShader, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.4645,
      "std": 0.1962,
      "unique_colors": 126
     },
     "image": "/specimens/water-caustics-realtime-specimen.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "fft-ocean",
  "gerstner-waves",
  "shallow-water-equations"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "shallow-water-equations",
   "why": "Height field normals feed the caustic refraction pass in an interactive pool."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/volumes/water-caustics-realtime.json"
 },
 "solves": [
  "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"
 ],
 "authority": "Wyman & Davis, 2006",
 "url": "https://texelatlas.vercel.app/t/water-caustics-realtime/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 9.32,
  "tier": "moderate",
  "p50_ms": 0.3065,
  "p95_ms": 0.3274,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "water-caustics-realtime-specimen",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 7.96,
   "tier": "moderate",
   "p50_ms": 0.1266,
   "p95_ms": 0.1278,
   "speedup_x": 2.42,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 5.26,
   "tier": "light",
   "p50_ms": 0.1516,
   "p95_ms": 0.1516,
   "speedup_x": 2.02,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}