Feature Library

Fire as a fluid

5.05 GPU · 0.23 CPU ms
A still of the Fire as a fluid demo
Still
The live demo starts when it’s in view.Drag to orbit round the fire

A box of air over burning ground stepped on the GPU every frame (advection, buoyancy, curl, a pressure solve) and drawn by marching each pixel’s ray through it.

What it costs a frame

5.05 ms
0.23 ms
GPU
5.05 ms
CPU, median
0.23 ms
CPU, 95th pct
0.39 ms
Draw calls
6
Compute passes
1
Weight
Heavy

Measured 3 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 156, 1920×1080 at 1×. 600 frames × 3 rounds, median kept. Phones: tiers are being measured next.

On every machine it was measured on
MachineGPU msCPU msCPU p95
RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring tool5.050.230.39
apple · Apple A19 Proin a browser tab · 16 November 20265.500.060.12
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 202638.50.821.13

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
WebGPU or WebGLWebGPU where there is one, WebGL2 where there is not.
Your browser
Runs hereNo WebGPU needed
Depends on
three.js 0.187.0No other packages

What it’s for

  1. Campfires and braziers
  2. Grass and brush fires
  3. Burning buildings or vehicles
  4. Smoke plumes
  5. Cinematic close-ups

Pitfalls, in brief

  1. Without WebGPU, pass renderer to createFire (or build FireVolumeGL yourself): three’s WebGL2 backend has no compute or storage buffers, so fire-volume-gl.ts steps the same cells as full-screen passes into float render targets, the box’s z slices laid side by side in a 2D texture, and the march reads two filtered slices a sample and mixes them where WebGPU reads one 3D texture.
  2. Without the pressure solve the heat never leaves the bottom cells: a cell only pulls from upstream if it already moves.
  3. Jitter the ray march per pixel with interleaved gradient noise; smooth noise leaves the march’s slices as scanlines.
  4. An orthographic camera needs parallel rays (the update checks the camera each frame).
  5. Compute pipelines are made on their first dispatch and the box’s draw on its first frame: call warm() at load (both sides: the eye may stand in the box), or the first fire freezes the frame for about a second.
5 more in brief
  1. Fog lit the box’s whole volume until the fire premultiplied after the fog: empty air must add nothing.
  2. A volume writes no depth: depth of field and anything reading depth see straight through it.
  3. Stage quality is eight times the cells and twice the steps: for one close-up, not a world full of fires.
  4. On a weak GPU pass tier (low: half the ray steps, one detail octave, fewer pressure iterations, the march at half the canvas each way): the march is nearly all the cost.
  5. A phone is far slower at the march than its other work (the A19 Pro took 27 ms a frame at the old low, about 17 times the RTX 4060): low now marches at half the canvas each way (scale, into its own target in update, which then needs the camera) and skips the shading of empty samples (sparse).
10 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

From HaTac. Fully custom code.

Jos Stam, Stable Fluids (1999): The step is the stable-fluids scheme: semi-Lagrangian advection and a Jacobi pressure projection. The algorithm, not code.

fluidcomputeray marchingvolumetricpressure solvestorage 3d texturetslrender-target ping-pongwebgl fallback

Near it in the frame