Skip to content

Compute & Particles

A hundred thousand particles moved entirely by the GPU, with no per-particle work on the CPU at all.

What you should come away with: What a compute shader is for, and the kind of problem that leaves WebGL behind entirely.

Assumes: Coordinate Spaces. It will still make sense without it, but that one comes first.

Why this API: WebGL has no compute shaders. This lab cannot be built on it — not slowly, not with a workaround. It is the clearest case for choosing WebGPU.

Checking for WebGPU…

What the GPU is doing

particles
60,000
workgroups
938
invocations
60,032
floats from CPU
8

938 workgroups of 64, dispatched once per frame, each invocation owning one particle. The equivalent in WebGL means encoding positions into a floating-point texture, stepping them in a fragment shader, ping-ponging between two framebuffers and reading them back as vertices — a well-known trick, and a workaround for a missing stage rather than a way of expressing the problem.