Feature Library

Volumetric mist with light shafts

9.31 GPU · 0.15 CPU ms
A still of the Volumetric mist with light shafts demo
Still
The live demo starts when it’s in view.Move the pointer through the mist to stir it · Pour for a cascade through the light

Cold mist from a quarter of a million GPU particles.

What it costs a frame

9.31 ms
0.15 ms
GPU
9.31 ms
CPU, median
0.15 ms
CPU, 95th pct
0.23 ms
Draw calls
0
Weight
Heavy

Measured 11 November 2026 on 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept. What ran: Measured with the default 262,144 particles, a 96 × 55 × 78 grid and 36 march steps at half size, the bowl brimming and a pour every nine seconds (the demo pours by itself while measured). All passes timed together with timestamp queries. Phones: tiers are being measured next.

On every machine it was measured on
MachineGPU msCPU msCPU p95
unknown GPU · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring tool9.310.150.23
apple · Apple A19 Proin a browser tab · 16 November 20268.100.380.60
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 20264.850.320.48

Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.

What it needs

Renders with
WebGPUNeeds WebGPU: current Chrome and Edge, Safari 26+, Firefox 141+ on Windows.
Your browser
Checking…Looking for WebGPU
Depends on
NothingNo other packages

What it’s for

  1. Dry ice and cold fog
  2. Mist pouring off a ledge or out of a vessel
  3. Light shafts through a window
  4. Stage and spotlight haze
  5. Ground fog in a scene
  6. Title and loading screens
  7. Dust in sunbeams through a window or between trees

Pitfalls, in brief

  1. Call simulate() once per submitted frame: the uniform is written with queue.writeBuffer, so every pass in the submit sees the last values written. preroll() submits each step on its own for that reason.
  2. The depth you give draw() is distance along the camera’s forward axis in a float colour texture (r32float), not a depth buffer: a depth24plus or depth32float texture cannot be bound as one.
  3. Atomics count in fixed point (1024 to a particle): beyond about four million particles in one cell a u32 overflows.
  4. The volume only exists inside its box: keep the light’s path and the haze you want to see inside it, and leave room above the floor.
  5. A grid finer than the particles can fill looks grainy (cells with one particle each): double the particles for every step up in grid, or raise Density less than you would think.
7 more in brief
  1. The mist is marched at half size and spread over full size by depth: an edge in front of the far dark would otherwise take the dark’s long fog in steps round it.
  2. Never queue more than one frame ahead (the demo skips a frame while the last is on the GPU): a quarter of a million particles a step piles up fast on a slow GPU.
  3. Never switch a volumetric pass on before the scene has drawn a frame.
  4. Dust drawn a pixel or less across twinkles: each mote lands on a different pixel every frame.
  5. Dust is lit by the mist’s volume (its green: the light reaching each cell), so it shows only in the light and dims in the mist’s own shadow; it is drawn over the mist, never behind it.
  6. Solids are at most eight boxes or upright cylinders, emitters at most eight: they live in one uniform.
  7. The demo needs WebGPU: the mist is stepped in compute, counted into its 3D grid with atomic adds, and smoothed, lit and marched through 3D storage textures, none of which WebGL 2 has.
12 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

From SpaciousPro. Fully custom code.

Henyey and Greenstein, phase function (1941): The mist’s forward glow looking into the light: the published formula.

Jarzynski and Olano, “Hash Functions for GPU Rendering” (JCGT 2020): Every random number (particles’ births, the wisps’ noise, the march’s jitter) is their PCG hash.

Bridson, Hourihan and Nordenstam, “Curl-Noise for Procedural Fluid Flow” (2007): The idea behind the swirl: the curl of a field is divergence-free, so the mist curls without bunching up. The field here (waves, two octaves) is the owner’s.

raw webgpuwgslcomputeatomicsvolume renderingray marchinggod rayscurl noisefogdust motessunbeams

Near it in the frame