Meshlets (cluster rendering) × GPU-driven rendering × Multi-Lobe Small-Angle Forward-Scattering Optical PSF Convolution × Real-time Water Caustics
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.
Open in StudioReproduced255× · 7.89 ms
Verified proof

Split-screen WebGL2 proof comparing raw crisp swaying meshlet kelp silhouettes with flat distance fog (left, showing harsh distant frond aliasing and sterile flat water) against GPU-driven swaying kelp forest layers composited with dual-layer refracted seabed caustics, red-heavy Beer-Lambert absorption, veiled sunlight shafts, and depth-gated small-angle underwater PSF forward-scattering blur (right).
Chromium Headless ANGLE/SwiftShader WebGL2 · 512x512 · replaces harsh distant kelp aliasing with physically grounded optical-depth small-angle PSF scattering, spectral absorption, and animated underwater caustics
Show GLSL proof (150 lines)
const float P_TURBIDITY = 1.00; // P Water Turbidity [0.2, 2.2, 0.05]
const float P_PSF_RADIUS = 1.15; // P Small-Angle PSF [0.0, 2.2, 0.05]
const float P_CAUSTICS = 1.25; // P Underwater Caustics [0.0, 2.5, 0.05]
const float P_SURGE = 1.00; // P Kelp Surge Sway [0.0, 2.0, 0.05]
float hash11(float p) {
p = fract(p * 0.1031);
p *= p + 33.33;
return fract(p * (p + p));
}
// Animated dual-layer refracted underwater caustic pattern
float evalCaustics(vec2 p, float t) {
vec2 q1 = p * 8.5 + vec2(t * 0.45, -t * 0.32);
vec2 q2 = p * 12.2 + vec2(-t * 0.38, t * 0.51);
float a = sin(q1.x + sin(q1.y * 1.3)) * cos(q1.y + cos(q1.x * 1.1));
float b = sin(q2.x - cos(q2.y * 1.2)) * cos(q2.y + sin(q2.x * 1.3));
return pow(clamp(0.5 + 0.5 * (a * 0.55 + b * 0.45), 0.0, 1.0), 4.2);
}
// Evaluates a multi-depth layer of swaying meshlet kelp stalks & fronds; returns (color, opticalDepth)
vec4 evalKelpScene(vec2 p, float t, bool withOptics) {
// Open ocean water column gradient
float yNorm = clamp(p.y + 0.5, 0.0, 1.0);
vec3 waterTop = withOptics ? vec3(0.08, 0.56, 0.64) : vec3(0.06, 0.34, 0.46);
vec3 waterBot = vec3(0.008, 0.065, 0.115);
vec3 col = mix(waterBot, waterTop, pow(yNorm, 1.35));
float depthOut = 10.0;
// Sunlit underwater volumetric shafts
if (withOptics) {
float shaftX = p.x * 4.5 + p.y * 1.8;
float shafts = pow(0.5 + 0.5 * sin(shaftX * 3.1 + sin(t * 0.45 + shaftX * 1.2)), 3.0);
shafts *= smoothstep(-0.35, 0.55, p.y);
col += vec3(0.14, 0.48, 0.54) * shafts * 0.52;
}
// Sandy reef seabed below y = -0.28
float bedY = -0.28 + 0.035 * sin(p.x * 5.2 + 0.8);
if (p.y < bedY) {
float dBed = clamp((bedY - p.y) / 0.25, 0.0, 1.0);
depthOut = mix(7.5, 1.8, dBed);
vec2 bedUV = vec2(p.x / max(0.35 + dBed, 0.2), 1.0 / max(0.18 + dBed, 0.15));
vec3 sand = vec3(0.52, 0.44, 0.30) * (0.85 + 0.15 * sin(bedUV.x * 16.0));
if (withOptics) {
float ca = evalCaustics(bedUV * 0.22, t) * P_CAUSTICS;
sand += vec3(0.35, 0.92, 0.86) * ca * 1.15;
vec3 absorb = exp(-depthOut * vec3(0.42, 0.14, 0.09) * P_TURBIDITY);
col = mix(col, sand * absorb, 0.92);
} else {
col = mix(col, sand * 0.55, 0.85);
}
}
// 5 depth-sorted kelp forest layers (back-to-front); each stalk subdivided into meshlet blade segments
for (int layer = 4; layer >= 0; layer--) {
float fl = float(layer);
float zDepth = 1.4 + fl * 1.75;
float scale = 1.0 + fl * 0.42;
int stalks = 4 + layer;
for (int s = 0; s < 8; s++) {
if (s >= stalks) break;
float seed = fl * 19.3 + float(s) * 7.13;
float x0 = (float(s) + 0.5) / float(stalks) * 1.15 - 0.575 + (hash11(seed) - 0.5) * 0.12;
// Shared surge wave sways kelp stalks smoothly
float sway = (0.045 + 0.025 * (p.y + 0.5)) * sin(t * 1.35 + p.y * 4.5 + x0 * 5.0 + fl) * P_SURGE;
float dx = (p.x - (x0 + sway)) * scale;
float stemW = 0.011;
// Alternating meshlet frond blades sprouting along stalk
float segY = (p.y + 0.5) * (9.5 + fl * 1.5);
float segIdx = floor(segY);
float segF = fract(segY) - 0.5;
float side = (mod(segIdx, 2.0) < 0.5) ? 1.0 : -1.0;
float bladeLen = 0.13 + 0.04 * hash11(seed + segIdx * 3.1);
float bx = dx * side;
float bladeCurve = 0.35 * bx * bx * 14.0;
float inBlade = step(0.0, bx) * step(bx, bladeLen) * smoothstep(0.32 * (1.0 - bx / bladeLen), 0.04, abs(segF - bladeCurve));
float inStem = smoothstep(stemW, stemW * 0.3, abs(dx));
float mask = clamp(inStem + inBlade, 0.0, 1.0) * smoothstep(0.46 - 0.05 * hash11(seed + 2.0), 0.32, p.y);
if (mask > 0.05) {
// Sun-lit golden-olive kelp frond albedo with subtle translucent backlight
float meshletId = mod(segIdx, 3.0);
vec3 frondAlb = mix(vec3(0.16, 0.34, 0.12), vec3(0.46, 0.54, 0.14), clamp(yNorm * 1.15, 0.0, 1.0));
if (!withOptics) {
// Left: subtle meshlet cluster bands visible without optical scattering
frondAlb *= (0.88 + 0.12 * meshletId);
} else {
float ca = evalCaustics(vec2(p.x, p.y) * 1.3 + fl * 0.4, t) * P_CAUSTICS;
frondAlb += vec3(0.28, 0.65, 0.42) * ca * (0.35 + 0.65 * inBlade) * exp(-zDepth * 0.25);
}
float rim = smoothstep(0.35, 0.95, inBlade) * smoothstep(-0.2, 0.5, p.y);
vec3 lit = frondAlb * (0.45 + 0.75 * yNorm) + vec3(0.30, 0.48, 0.12) * rim * 0.45;
if (withOptics) {
vec3 absorb = exp(-zDepth * vec3(0.38, 0.12, 0.08) * P_TURBIDITY);
vec3 veil = mix(vec3(0.02, 0.14, 0.20), vec3(0.10, 0.46, 0.52), yNorm);
lit = mix(veil, lit * absorb, exp(-zDepth * 0.16 * P_TURBIDITY));
} else {
lit = mix(vec3(0.03, 0.16, 0.24), lit, exp(-zDepth * 0.12));
}
col = mix(col, lit, mask);
depthOut = mix(depthOut, zDepth, mask);
}
}
}
return vec4(col, depthOut);
}
vec3 acesTone(vec3 x) {
return clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
bool usePSF = uv.x > 0.0;
vec2 p = vec2(usePSF ? (uv.x - 0.25) : (uv.x + 0.25), uv.y);
p.x *= 1.85;
vec3 col = vec3(0.0);
if (!usePSF) {
col = evalKelpScene(p, iTime, false).rgb;
} else {
vec4 center = evalKelpScene(p, iTime, true);
float optDepth = center.a;
// Depth-gated small-angle underwater Point Spread Function (PSF): near kelp stays razor sharp,
// distant kelp blurs into luminous aquatic forward-scattered halos
float psfR = clamp((optDepth - 1.6) * 0.0042 * P_PSF_RADIUS * P_TURBIDITY, 0.0, 0.032);
vec3 acc = center.rgb * 0.34;
float wSum = 0.34;
if (psfR > 0.001) {
for (int i = 0; i < 8; i++) {
float a = float(i) * 0.785398;
vec2 off = vec2(cos(a), sin(a)) * psfR;
vec4 s = evalKelpScene(p + off, iTime, true);
// Depth-gated weight prevents foreground kelp from bleeding onto background water
float depthGate = smoothstep(optDepth - 1.8, optDepth - 0.2, s.a);
float w = 0.0825 * (0.25 + 0.75 * depthGate);
acc += s.rgb * w;
wSum += w;
}
}
col = acc / wSum;
// Subtle floating marine snow backscatter specks
float sp = fract(sin(dot(floor((p + vec2(0.0, -iTime * 0.02)) * 95.0), vec2(12.9898, 78.233))) * 43758.5453);
col += vec3(0.32, 0.62, 0.66) * smoothstep(0.992, 0.999, sp) * 0.35;
}
col = acesTone(col);
if (abs(uv.x) < 0.003) col = vec3(0.95, 0.93, 0.89);
fragColor = vec4(pow(clamp(col, 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Why they connect
Meshlets (cluster rendering) partitions high-detail kelp stalks, bladders, and reef rocks into small triangle clusters with tight bounding spheres and normal cones. GPU-driven rendering culls those mesh clusters on the GPU against the view frustum and Hi-Z pyramid, applies surge-current vertex sway, and emits indirect draw commands that populate the scene depth and lit G-buffer. Real-time Water Caustics reads that depth buffer alongside animated surface wave normals to project shimmering caustic bands onto both kelp fronds and seafloor. The hop to Multi-Lobe Small-Angle Forward-Scattering Optical PSF Convolution is composite: the caustic-lit HDR radiance and linear scene depth enter a depth-modulated forward-scattering PSF convolution (paired with wavelength-dependent Beer-Lambert absorption and in-scattering), producing realistic distance-dependent halation around bright sunlit silhouettes.
How to build it
Offline or at load time, run meshoptimizer to split kelp frond archetypes and reef props into 64-vertex/124-triangle meshlets with bounding cones. In a WebGPU or Vulkan compute pass, frustum- and Hi-Z-cull instanced meshlets and write surviving meshlet descriptors into an indirect draw buffer, animating blade sway in the vertex stage from a shared surge-wave field. Project animated dual-layer refracted caustics onto shaded surfaces using reconstructed world position from the depth pass. Finally, build a mip pyramid or separable multi-radius filter of the lit HDR buffer and blend depth-gated small-angle PSF kernels (parameterized by turbidity and optical depth) on top of red-heavy exponential absorption and veiled sunlight backscatter.
Field marks
- Large vertex sway invalidates static meshlet bounding spheres unless bounds are conservatively inflated by maximum surge amplitude.
- Depth-varying PSF blur bleeds bright sunlit surface pixels over dark foreground kelp stalks unless foreground depth occlusion masks the gather.
- Alpha-tested or ultra-thin kelp edges shimmer under Hi-Z occlusion and need conservative depth pyramids or solid ribbon geometry.
- Over-blurring distant silhouettes can hide caustic motion unless direct transmission and forward-scattered glow are balanced by optical depth.
Prior art
- mrdoob/codevember-2026. Open-source underwater kelp scene combining GPU-driven meshlets, real-time caustics, and small-angle underwater PSF scattering; listed here as an open Arena cross awaiting a standalone WebGL2 reproduction.