r/GraphicsProgramming • u/cat6boo • 15m ago
Reconstructing a 3.63M-voxel WebGL2 DDA coastal wave scene from a zero-parallax handheld phone pan (brick-accelerated raymarcher + write-up)
I wanted to see if I could turn a 10s standing smartphone pan of crashing waves into a real-time 3D scene you can freeze, orbit, and relight in WebGL2. Classic SfM / 4D Gaussian Splatting failed immediately because a standing pan has almost zero translation baseline (-66px foreground rock shift vs -61px cloud shift over 10.2s).
Here is the deterministic extraction + rendering pipeline I ended up with (interactive WebGL2 demo, <600 KB gzipped: https://ottershrine.github.io/coastal-voxels/ ):
- Camera recovery: Subpixel patch-median tracking across 6 dry-rock patches + horizon gradient recovers yaw (-4.6° to +14.5°) and pitch (-10.9° to -8.2°) across 309 frames.
- Surf erasure / rock recovery: Warping 103 frames into a shared panorama and taking the 15th-percentile darkest pixel strips out white breaking surf and exposes 243 dark wet intertidal rocks.
- Sea field projection: Per-frame foam brightness and dark crest-face contrast are inverse-projected onto Y=0 to build a dynamic height/foam grid (downsampled to 96×54×70 gzipped = 546 KB for the web build).
- WebGL2 DDA raymarching: A single fragment shader traverses a 512×120×416 R8 rock volume accelerated by an 8×8×8 occupancy brick grid, combined with procedural overhanging curling wave lips, Voronoi foam webs, 6-ray hemisphere AO, and depth-tested instanced 3D spray cubes (1.5× SSAA RGBA16F + bloom).
AI disclosure (Rule 5): I used Gemini Neon as a coding assistant to iterate on the extraction scripts and WebGL2 shaders. There is zero neural inference, diffusion, or ML running at render time - everything in the video and browser demo is pure WebGL2 DDA math.
Happy to share shader details on the brick DDA traversal or foam projection if anyone's curious. (I also post more WebGL/voxel breakdowns on X at https://x.com/ottershrine )



