Particle pool for 2D games: effects as data, a flat cost
3.41 GPU · 0.51 CPU ms
Still
The live demo starts when it’s in view.Watch it fly itself, or take over: WASD or the arrows fly, Space dashes, hold to steer. In use as a page: press, send and book
The effects layer of a 2D game on one GPU ring of 131,072 slots in raw WebGPU.
The game fires recipes from its events (fx.fire('kill', x, y)); compute spawns and steps every slot and one instanced draw shows them, so the cost is the same at none alive or all of them and fits a written budget. Recipes are plain data: bursts of sparks, embers and chips with ramps, cones, streaks, drag and swirl, plus a shockwave that bends the picture, a flash, a light and shake hints for game-feel-2d. Shockwaves, moving bodies and attractors act on everything in the pool; fields are particles with a home that light up when stirred; ribbons trail dashes and shots. The engine’s bloom and a finish pass (clean, a restricted palette with dither and pixel size, or a CRT) end the frame. Hand it your Canvas 2D canvas as the scene and the swap is an afternoon. On a web page it is a see-through layer that takes no clicks, fired from elements (a press, a form sent, a card arriving, an order placed) in page coordinates, asleep while nothing is alive. Without WebGPU the same API runs on Canvas 2D with smaller counts.
What it costs a frame
GPU
3.41 ms
CPU
0.51 ms
02468101216.7 ms
GPU
3.41 ms
CPU, median
0.51 ms
CPU, 95th pct
0.84 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 3.04–3.48, CPU 0.48–0.52 ms). What ran: The pool alone, full stage: 131,072 slots stepped and drawn every frame (90,000 field motes, the rest bursts fired on a timer: blasts, hits, pickups pulled to a point, a ribbon), shockwaves bending the frame, bloom and the clean finish. No scene canvas is copied. Phones: tiers are being measured next.
NVIDIA GeForce RTX 4060 Laptop GPU · 13th Gen Intel(R) Core(TM) i9-13900Hmeasuring tool · 28 November 2026
2.42
0.67
1.12
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.90 ms
1% low ?
55 fps
Varies by ?
±0.48 ms
All metricsRTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900H · referenceHow 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.90 ms
p95 ?
17.83 ms
p99 ?
18.02 ms
Slowest ?
18.50 ms
Mean ?
16.93 ms
Standard deviation ?
0.48 ms
1% low ?
55 fps
0.1% low ?
54 fps
Hitches ?
0 of 600
Over budget ?
0 of 600
Main thread
Long tasks ?
0
Long frames ?
0
Event-loop delay ?
0.1 / 0.7 / 0.9 ms
Input
No input during this run.
Memory
JavaScript heap ?
33.1 → 32.9 MB
Growth ?
-0.20 MB
Browser
JavaScript a frame ?
0.56 ms
All tasks a frame ?
1.15 ms
Layout / style ?
0.00 / 0.00 ms
Main thread busy ?
7%
Garbage collection
Collections ?
3 (2 minor, 1 major)
Pauses ?
8.5 ms in all, longest 2.0
All metricsNVIDIA GeForce RTX 4060 Laptop GPU · 13th Gen Intel(R) Core(TM) i9-13900H · measuring toolHow 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.75 ms
p99 ?
18.00 ms
Slowest ?
18.63 ms
Mean ?
16.89 ms
Standard deviation ?
0.49 ms
1% low ?
55 fps
0.1% low ?
54 fps
Hitches ?
0 of 600
Over budget ?
0 of 600
Main thread
Long tasks ?
0
Long frames ?
0
Event-loop delay ?
0.1 / 1.0 / 1.3 ms
Input
No input during this run.
Memory
JavaScript heap ?
32.8 → 31.8 MB
Growth ?
-1.00 MB
Browser
JavaScript a frame ?
0.73 ms
All tasks a frame ?
1.23 ms
Layout / style ?
0.00 / 0.00 ms
Main thread busy ?
7%
Garbage collection
Collections ?
7 (5 minor, 2 major)
Pauses ?
15.5 ms in all, longest 2.2
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("particle-pool-2d")Your coding agent reads its pitfalls and installs it through the library’s MCP server. Set it up
What it’s for
Hits, kills, pickups, dashes and muzzle flashes in a 2D action game, fired from its events by name
Replacing a Canvas 2D game’s hand-written particle loops in an afternoon, keeping its own drawing
Shockwave rings that bend the picture and throw every spark and mote outward
A floor, a sky or water of tens of thousands of motes that the player and enemies stir as they move
A pixel-art or CRT finish over a whole 2D game, with bloom, as one tone setting
Lights from effects handed to a 2D lighting pass, without reading anything back from the GPU
A celebration when an order is placed, sparks on a primary action, light round a card as it arrives on an expressive page
A see-through effects layer over or behind a page that never blocks a click and sleeps when nothing is happening
Pitfalls, in brief
The cost is flat on purpose: every slot is stepped and drawn each frame, alive or not.
The pool is a ring: when bursts fire faster than they die, the oldest live particles are overwritten.
Fields take slots from the start of the pool and bursts share what is left (at least an eighth is kept for bursts).
A Canvas 2D scene is copied to the GPU every frame (copyExternalImageToTexture).
With background 'transparent' the pool lays over the game’s canvas and cannot bend it: shockwaves show their rim and push particles, nothing more.
10 more in brief
Pass the real frame time as dt and the hit-stop’s share to your game.
World units are what your camera uses: pass view (centre and pixels per unit, shake added) every frame.
Everything is light by default (added); opacity near 1 makes solid chips that cover, drawn in the ring’s order.
Reduced motion drops flashes and shake hints, softens shockwaves and field impulses.
alive() is an upper bound worked out on the CPU from what was fired and the longest life of each burst; nothing is read back from the GPU.
On a page, use it on expressive pages only (a launch, a shop, a game’s site).
A page layer fires nothing with reduced motion, while the tab is hidden or while its host is off screen.
Page coordinates are the scroller’s content in CSS pixels.
Light adds to what is under it, so on a white page bright light can vanish into the white.
The Canvas 2D tier draws the same recipes on a few thousand slots: no bloom, rings drawn instead of bent, and palette drawn as clean.
15 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: The HaTac engine’s bloom chain (Karis-weighted downsample, tent upsample, settle) and the pool written for the library.
Martin Roberts: The R2 sequence that spreads a field’s homes evenly without a grid.
A field of characters wakes: every glyph lifts off its cell, rises on a curl flow into a few rivers of light, runs along them and pours into a word, where one…
Birds, butterflies, fireflies, drones or darts that flock freely on the GPU, then each fly to their own point of a word or a shape, hold it and let go again.
A title moment for a stage or a launch: the camera races in at lightspeed behind falling lights, the stars streaking past, brakes hard into their trails and…