How it works

How it works

The bright net on a pool floor is light that the waves have focused. Each wave crest acts as a weak lens, and where a lens brings its light to a line you get a caustic. This page traces that literally. Every frame, a grid of 126,000 sun rays (461×274 at 2560×1440) is bent by the slope of the water and dropped onto the floor. Each ray carries a small triangle of light. Where the triangles crowd together the floor is bright, and where a triangle folds flat you get a knife-edge filament. The water itself is 24 analytic wind waves plus a real wave-equation simulation that your cursor pushes through. Its wake is a set of rings that spread at walking pace, and a low swell along your path, filled with short chop, that takes about six seconds to settle. So a band of dense, bright filaments trails behind you.

Pipeline (per frame)

pointer ─▶ JS   path since the last step → sim texels; |v − c| / c → trough gain; stroke length → ramps
               wind + chop phases φᵢ += ωᵢ·speed·dt, wrapped
               N = accumulator × 120 steps/s  →  2 steps per 60 Hz frame (capped at 8)
 ┌── N × WAVE   RGBA32F 461×274 ping-pong, NEAREST, texelFetch     (screen + a 7% border on every side)
 │       r,g  leapfrog (h, h_prev), isotropic 9-point Laplacian, C² = 0.36, Kelvin–Voigt viscosity
 │            amplitude e-fold = Wake linger (4 s) for long waves, absorbing sponge in the border
 │            + fused moving trough A→B along the pointer path, impulse × 1/(1 + 8h²)
 │            + release: where a stroke ended, h and h_prev relax toward 0 over 0.1 s
 │       b    wake swell: raised toward 0.42 by the capsule A→B, e-fold 1.5 × Wake linger (6 s)
 └─────────────────────────────────────────────────────────────────────────────────────────────
 SURF     RGBA16F 461×274, LINEAR   ∇h = Σ₂₄ crest-peaked wind waves × (1 − 0.35·band)
                                         + Σ₆ wake chop (0.38 × the wavelength) × band
                                         + tanh-limited slope of (ripple + swell)
 CAUSTIC  light mesh: one vertex per SURF texel, triangle strips + primitive restart, no vertex buffer
          ray x lands at x + F·depth(y)·∇h(x);   I = |det ∂(source)| / pixel area   (flat = 1)
          2 instances: red at F·(1−δ), blue at F·(1+δ)                     (502k triangles)
          → RG16F 1076×605, 4× MSAA renderbuffer (2× on touch), additive ONE+ONE, no culling → blit
 BLUR     RG16F 1076×605, separable Gaussian, ≤13 taps (9 in Pool), σ = sun disc × √focus × depth(y),
          never below 0.3 of the mesh pitch
 BLOOM    RG16F 539×303, threshold (I − 1.4) + separable blur          (skipped when Glow = 0)
 DISPLAY  canvas 2560×1440, opaque
          bilinear ∇h → refracted view of the floor → albedo (mosaic, lane, rippled sand, plain)
          green = min(r, b) + 0.35·|r − b|;   water filter T = hue^(0.6·tint·depth)
          × (fill · relief · T² + sun · I^γ · relief · T + glow) → in-scatter by depth
          + sun glitter: one facet per 20 px cell → shoulder tonemap → sRGB → ±1 LSB triangular dither
 ≈ 7 draws + 1 blit per frame (9 with Glow)

The ideas that matter

Parameters

Presets

Performance & compatibility

References & credits