AERO Wave Lab

GPU ping-pong wave solver + raymarched volumetric fog. Click the water to drop ripples.
Drag orbit · Wheel zoom · Click water ripple

GPU Ping-Pong Waves & Volumetric Fog Raymarching

Read the explanation

AERO Wave Lab couples a discrete two-dimensional wave equation with real-time volumetric fog raymarching. In the wave shader, height evolves by subtracting previous height from twice current height, adding the four-neighbor Laplacian, and multiplying by damping. Next, the volumetric fog marches view rays. Local density drops exponentially with elevation above the simulated water crests. Clicking the water injects a Gaussian ripple pulse, while the HUD controls let you balance wave speed, damping, and sun lighting.

GPU Ping-Pong Wave Equation and Volumetric Fog Raymarching

How do ping-pong render targets solve dynamic water waves and how does raymarching render light scattering through fog?

AERO Wave Lab pairs two real-time graphics techniques: an explicit 2D wave equation integrated on a ping-pong render target, and a screen-space volumetric raymarcher. The wave solver evaluates a discrete discrete-Laplacian stencil across neighboring texels to update surface elevations each frame. The fog shader then casts rays from the camera through a participating medium, accumulating in-scattered sunlight modulated by an anisotropic phase function and attenuated by exponential Beer-Lambert optical depth.

The wave simulator uses an uncalibrated finite-difference stencil without physical spatial units, depth boundaries, or Courant-Friedrichs-Lewy stability checks. The volumetric fog evaluates fixed 32-step ray segments with heuristic absorption and scattering coefficients rather than calibrated atmospheric particle distributions.

Try a worked example

Clicking the 'Pause' button toggles the simulation from running to frozen. In the running state, the button displays 'Pause'. When clicked, the script halts the render target ping-pong step, and the button label switches to 'Play' with the 'active' CSS class applied, allowing you to examine frozen wave profiles and fog silhouettes.

Ping-Pong Discrete Wave Integration

The wave solver stores surface elevations across two alternating 512x512 half-float render targets. In each step, the fragment shader reads the current elevation from the red channel and the previous elevation from the green channel. It approximates the spatial Laplacian using a four-neighbor cross stencil (left, right, up, down minus four times center), scales by speed squared, advances time via Verlet-style integration (next = (2 * curr - prev + laplacian) * damping), and writes next into red and curr into green.

Volumetric Raymarching & Optical Depth

The fog post-processing pass reconstructs world-space view rays from depth buffer samples and marches 32 discrete steps per pixel toward the scene geometry. Along each step, local fog density decays exponentially with height above the reconstructed water surface. Accumulated radiance combines background scene color attenuated by transmittance with in-scattered sunlight, matching the discrete volume compositing framework described by NVIDIA Developer volume rendering literature. Chapter 39. Volume Rendering Techniques | NVIDIA Developer

At each ray segment, transmittance decreases according to the Beer-Lambert law, multiplying previous transmittance by exp(-density * stepSize * 1.8). Sunlight in-scattering incorporates forward scattering via a Henyey-Greenstein phase function with asymmetry parameter g = 0.7, directing more scattered sunlight along glancing angles toward the camera. Chapter 39. Volume Rendering Techniques | NVIDIA Developer

Sources and further reading
Super generates helpful tools and automates fact-checking across the internet proactively. If you enjoyed this tool, build your own with Super and share it with a friend.