← All guides Qalarc
On this page
Qalarc Guides · GPU shaders

Building GPU Grass + Fire: The Grass-Fire Lab

2026-11-16 studio #games#web#tools ~10 min read
How the Grass-Fire Lab renders hundreds of thousands of GPU-instanced grass blades and spreads wildfire through them — instancing, wind fields, cellular fire spread and LOD — plus what nine versions of the lab taught us. Playable in the browser, desktop or phone.

What the lab is

The Grass-Fire Lab is an interactive wildfire-on-grass system built for games: a GPU-instanced field of grass, a cellular fire simulation that actually runs through it, wind, audio and biome randomisation. Click the ground to ignite; press T to throw a fireball; watch flames chase the wind and leave black ground behind. It's playable right now:

▶ Play the current build (v7.17 · desktop) grass-fire-lab.pages.dev →

It looks like a tech demo. It's actually the research bench for the studio's games — the terrain, instancing and fire systems feed DUSKRUNNER 2 and the other Qalarc games, and every finding below was learned by shipping a version and breaking it[1].

Architecture in one paragraph

Everything is three.js + custom GLSL, zero game engine. One InstancedBufferGeometry holds a single blade; a per-instance attribute buffer holds position, rotation, height, colour variation and a state word (bend / cut / heat / burnt). The vertex shader bends and sways each blade; the fire simulation runs on a CPU-side state grid and streams dirty cells to the GPU each frame; the ground mesh re-shades itself from the same state. No textures define the grass — every blade is math[2].

The grass

Blades: one geometry, N instances

Each blade is a thin tapered strip — a handful of vertices with a bend curve baked into UVs. The instance matrix places it; a hash of the instance ID gives per-blade variation (height, lean, hue jitter) so the field never shows repetition. Because every blade shares one geometry, the whole field of hundreds of thousands of blades is a single draw call.

Wind: two layers of noise

The vertex shader displaces blades with two noise layers: a large slow gust field that rolls across the meadow, and a fast small flutter per blade. Wind direction is a uniform, so turning the wind visibly re-lays the whole field — and the fire system reads the same field, which is what makes the two systems feel connected.

Biomes

Current builds randomise per-session biomes — wheat and flower mixes over the standard sward — by swapping the blade colour ramp, density and height distributions. Same shaders, different constants.

The fire

Cellular spread on a state grid

Fire is a cellular automaton over a grid laid across the terrain. Each cell carries fuel and heat. A burning cell injects heat into neighbours each tick, biased downwind; a cell with heat over ignition threshold and fuel remaining catches; fuel burns down; when it's spent, the cell turns burnt and the ground shader renders it black. That's the entire simulation — and it's enough for fire front lines, wind-driven flanks and burnout trails that read as "real" because they follow the same physics intuitions players already have[3].

// the tick, minus the tuning constants
for (cell of dirtyCells) {
  heat[cell] += windBias * neighboursHeat;
  if (heat[cell] > IGNITE && fuel[cell] > 0) state[cell] = BURNING;
  if (state[cell] == BURNING) fuel[cell] -= burnRate;
  if (fuel[cell] <= 0)        state[cell] = BURNT;
}

Rendering: flames, embers, light

Burning cells spawn shader-drawn flame quads — the current build's "tendril comet" flame with a fresnel core comes from v7.17's renderer rework — plus embers that ride the same wind field. Burning cells also register as point lights for the ground pass, so fire genuinely illuminates the grass around it. Cheap additive quads over the cellular truth, never a particle system pretending to be fire.

Interaction

Left-click raycasts the terrain to ignite a cell; T throws a fireball whose tip glows (v7.8's "first tip glow") and ignites on impact. The mobile build gets a touch action bar and save state, so phones ignite fires just as well as desktops.

Performance and the LOD slider

The lab ships a quality selector (mid_high by default) and a live LOD slider: blade count, shadow grass distance and simulation grid density scale together. On desktop GPUs the full field holds frame rate easily; on phones the mobile preset trades blade density for the same 60fps target. The pattern worth stealing: the state grid and the blade field are decoupled — you can halve the grass without touching fire behaviour at all.

BuildWhat it proved
v7.2.0Extraction baseline — the lab as a standalone repo
v7.4.0Death pacing presets (and a historic shader bug — grass may vanish; kept as reference)
v7.7.0Ramp sprites + real sounds — audio makes fire feel 2× bigger
v7.8.0Fireball v2 with the first tip glow
v7.17 (current)Tendril comet + fresnel flame, mobile action bar + save, wheat/flower biomes, LOD slider

What we learned

Take it apart. The lab runs in the browser — open devtools, watch the draw calls, and try the older versions listed on the lab index to see each system appear.

Notes & sources

  1. The lab index lists every playable version from v7.2.0 to the current v7.17, with per-version change notes: qalarc.com/labs/grass-fire/. ↩
  2. GPU-instanced sward, cellular fire, wind and biome randomisation are the lab's documented feature set; the build history lives in the lab repo's iterations/README.md. ↩
  3. If you want the deeper state-map approach (bend/cut/heat per texel with dirty-rect uploads), our patch.gg research notes on touch-grass cover the grass-that-remembers variant: patch.gg/blendi/touch-grass. ↩

Discussion …

Footnote numbers above link here — corrections, better methods and "actually this broke for me" are all welcome.

Ask the Qalarc guide