Feature Library

Lit arena: 2D light, soft shadows, smoke and fire that answer play

8.27 GPU · 0.80 CPU ms
A still of the Lit arena: 2D light, soft shadows, smoke and fire that answer play demo
Still
The live demo starts when it’s in view.Click to set off a blast; Blast, Flare, Gust and Hold fire on the stage; arrows aim and Enter fires from the keyboard. Lit page: move the pointer to carry a lantern, press Strike a light

A 2D scene lit only by what happens in it.

Each frame the game lists its walls, bodies and lights (shots, sparks, braziers, flares, blasts) and pushes on the smoke; lit-arena lights them with radiance cascades over a distance field rebuilt by jump flooding, so every wall and body casts a soft shadow, glazed walls throw their colour back, and the frame costs the same with ten lights or a thousand. Smoke and fire run on a screen-sized stable-fluids grid: blasts push smoke out in rings, bullets cut lanes through it, the wind carries it, and fire lights its own smoke from inside, because the cascades march through the grid. Soot stays where things burned. On a web page (mountLitPage), the same light sits on a transparent canvas behind the content: headings, cards and images are read from their DOM rects as walls that cast soft shadows and bounce their colour, the pointer carries a lantern, a press strikes a flash, text stays crisp and never drops below 4.5:1 contrast, it rests when idle and off screen, shows one still lit frame under reduced motion, and falls back to CSS gradients without WebGPU. Raw WebGPU with its own bloom and grade, a Canvas 2D tier (soft light pools and puff smoke, no shadows) where WebGPU is missing, three quality tiers, and reduced motion that eases flashes into swells. No textures, models or dependencies.

What it costs a frame

8.27 ms
0.80 ms
GPU
8.27 ms
CPU, median
0.80 ms
CPU, 95th pct
1.23 ms
Draw calls
0
Weight
Heavy

Measured 28 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 158, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged GPU 7.29–8.71, CPU 0.80–0.89 ms). What ran: The bare court alone, full stage: 400 drifting lights, four braziers, a smoke pot and a blast every 3.5 s. The light field (radiance cascades over a jump-flood distance field) and the smoke grid are sized by the stage, not by the lights; the number is the whole frame, smoke step to present. 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 tool8.270.801.23
NVIDIA GeForce RTX 4060 Laptop GPU · 13th Gen Intel(R) Core(TM) i9-13900Hmeasuring tool · 28 November 20265.66<0.01<0.01

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.

How steadily it runs on RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900H · reference

Typical frame ?
16.84 ms
1% low ?
53 fps
Varies by ?
±0.52 ms
All metricsRTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900H · reference
p50p95p9916.04 ms18.25 ms +
How long each frame took. Most frames sit in the tall bars; a long tail to the right is hitching.

Frames run on a 60 Hz timer (a page demo), so most frames take about one tick, 16.7 ms: the spread around it is what matters.

Frames

Median (p50) ?
16.84 ms
p95 ?
17.77 ms
p99 ?
18.12 ms
Slowest ?
21.80 ms
Mean ?
16.89 ms
Standard deviation ?
0.52 ms
1% low ?
53 fps
0.1% low ?
46 fps
Hitches ?
0 of 600
Over budget ?
0 of 600

Main thread

Long tasks ?
0
Long frames ?
0
Event-loop delay ?
0.1 / 1.1 / 17.3 ms

Input

Interactions ?
2
Input to paint ?
10.3 ms, worst 17.9
Longest handler ?
0.2 ms

Memory

JavaScript heap ?
33.0 → 33.6 MB
Growth ?
+0.61 MB

Browser

JavaScript a frame ?
0.79 ms
All tasks a frame ?
1.34 ms
Layout / style ?
0.00 / 0.00 ms
Main thread busy ?
8%

Garbage collection

Collections ?
19 (19 minor, 0 major)
Pauses ?
9.6 ms in all, longest 1.0
All metricsNVIDIA GeForce RTX 4060 Laptop GPU · 13th Gen Intel(R) Core(TM) i9-13900H · measuring tool
p50p95p9916.18 ms35.04 ms +
How long each frame took. Most frames sit in the tall bars; a long tail to the right is hitching.

Frames run on a 60 Hz timer (a page demo), so most frames take about one tick, 16.7 ms: the spread around it is what matters.

Frames

Median (p50) ?
17.18 ms
p95 ?
22.91 ms
p99 ?
23.14 ms
Slowest ?
62.27 ms
Mean ?
18.06 ms
Standard deviation ?
2.97 ms
1% low ?
28 fps
0.1% low ?
16 fps
Hitches ?
3 of 600
Over budget ?
3 of 600

Main thread

Long tasks ?
0
Long frames ?
0
Event-loop delay ?
5.5 / 6.1 / 51.5 ms

Input

Interactions ?
1
Input to paint ?
33.2 ms, worst 33.2
Longest handler ?
0.8 ms

Memory

JavaScript heap ?
32.4 → 32.6 MB
Growth ?
+0.24 MB

Browser

JavaScript a frame ?
8.15 ms
All tasks a frame ?
17.80 ms
Layout / style ?
0.00 / 0.00 ms
Main thread busy ?
99%

Garbage collection

Collections ?
10 (5 minor, 5 major)
Pauses ?
14.3 ms in all, longest 1.6

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
With an agent
install("lit-arena")Your coding agent reads its pitfalls and installs it through the library’s MCP server. Set it up

What it’s for

  1. A top-down or twin-stick shooter whose shots, sparks and blasts are its only light
  2. A dungeon or cave crawler lit by torches and spells, with soft shadows behind every pillar
  3. Smoke grenades, burning crates and gusts that change what the player can see
  4. A stealth game where shadows and smoke decide who is seen
  5. A menu or title screen with drifting lanterns in a dark room
  6. Neon signs and lit windows glowing on wet streets in a 2D city
  7. Teaching light transport: bounce, soft shadows and participating media you can poke
  8. An expressive landing page or hero whose headings and cards cast soft shadows from a lantern the pointer carries
  9. A portfolio or event page lit by a button press, with its text kept at 4.5:1 contrast

Pitfalls, in brief

  1. The cost follows the screen, not the lights: the light field is half the CSS pixels at the high tier (600,000 texels at most) with one cascade texture twice its size, and every cascade casts as many rays as the field has texels times four.
  2. Lights must be at least a pixel and a half wide in the picture or they slip between the field’s texels and flicker as they move.
  3. Smoke blocks light, so a blast laid as a solid disc of smoke shut its own flash inside the cloud and the court never lit.
  4. 2D light falls off as one over distance, not its square, so a hundred small lights flood the floor evenly.
  5. Bounce is one bounce a frame, from last frame’s light: a lit wall glows a frame late, and after a cut or a reset the bounce takes a few frames to build.
11 more in brief
  1. Merging cascades bilinearly can leak a little light through walls thinner than the coarsest probe spacing (32 field texels at most).
  2. The smoke steps against last frame’s walls (the grid runs before this frame’s shapes are drawn): a wall that appears this frame stops smoke from the next one.
  3. Wall tops are lit by the light just outside their faces, sampled in rings up to 40 world px out: a wall wider than about 80 px goes dark in its middle, which reads as a tall wall from above.
  4. The Canvas 2D tier has soft light pools, puff smoke, fire glow and soot, but no shadows, no bounce and no views; it draws at most 320 lights (the brightest) and 700 puffs.
  5. One arena makes one WebGPU device unless you hand it yours (device option).
  6. Lit pages are for expressive sites: a landing page, a hero, a portfolio.
  7. The contrast guard reads the root’s background and the colours of the text that sits on it (text on its own opaque box, like a card, is left out) and, within 12 px of each text box (easing out by 72 px), keeps the background inside the luminance range that holds 4.5:1 for every one, or the text’s own starting contrast if lower.
  8. The page canvas covers the root element exactly and is sized to it: mount it on a hero or a section, not a whole long page, and give the root no scrolling of its own.
  9. On a flat page background the coarse cascades leave faint blocks round small lights, which a textured floor hides.
  10. A text-only element is a veil, not a wall: light passes through the box round its text, dimmed (letters have gaps), so it casts a soft partial shadow and the light under it is real.
  11. Under reduced motion the light eases toward each frame’s value (about a fifth of the way a frame), so a flash swells and fades instead of striking; the game should still drop its own screen shake and big flashes.
16 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

Written for the library. Fully custom code.

Hannes Andersson: Feature Library effect and demo.

Alexander Sannikov: Radiance cascades: probes whose ray count grows and spacing widens by cascade, each casting a farther interval, merged top down. Written out here from the paper’s description; no code taken.

Guodong Rong and Tiow-Seng Tan: Jump flooding (2006): the distance field the rays step along, rebuilt each frame in log2(size) passes. Written from the method’s description.

Jos Stam: Stable fluids (1999): semi-Lagrangian advection and a pressure projection; vorticity confinement after Fedkiw, Stam and Jensen (2001). Written from the papers’ descriptions.

2d lightingglobal illuminationradiance cascadessoft shadowsbounce lightcoloured lightjump floodingdistance fieldsdfsmokefirestable fluidsvorticityfluid gridexplosionstracersmuzzle flashtop-downtwin-stickarenagameemissivemany lightsfixed cost

Near it in the frame