WebGPU · runs on your GPU

Gravity

A real N-body simulation. Tens of thousands of stars, each one pulling on every other, recomputed every single frame on your graphics card. Spawn a galaxy, slam two together, or drag your cursor to bend the field.

⚡ 100% on-device — your GPU does the physics, nothing is uploaded
starting…
drag to pull stars · scroll to zoom
1.0
1.0
1.0

This needs WebGPU

Your browser can't run the simulation yet. WebGPU works in recent Chrome, Edge, and other Chromium browsers, and in Safari 26+. Open this page on a desktop with a GPU for the full effect.

What you're looking at

This is a gravitational N-body simulation. Each glowing point is a star with mass, position, and velocity. On every frame the simulation works out the gravitational pull between each star and every other star using Newton's inverse-square law, adds it all up, and nudges each star along. Run it long enough and a flat disk winds itself into spiral arms, two galaxies tear each other into tidal streams, and a cold cloud collapses into knots — all from nothing but gravity.

How does this run in a browser tab?

The honest answer is that it doesn't run on your CPU. Computing the pull between every pair of stars is an all-pairs problem: with sixteen thousand stars that's around a quarter of a billion force calculations, and it has to happen sixty times a second. JavaScript on a single core would manage a slideshow. Instead this uses WebGPU, the new browser API for talking to your graphics card directly. The force loop is written as a compute shader and run across thousands of GPU threads at once, with each block of stars streamed through fast on-chip workgroup memory so the GPU isn't constantly waiting on slow reads. It's the same tiling trick that real GPU physics engines use. Your graphics card was built for exactly this, and the whole thing stays on your machine — there's no server in the loop.

Things to try

Hit Galaxy collision and watch the two cores swing past each other and fling out long tidal tails. Drop the Speed to zero, then nudge it up to step through the dynamics slowly. Press and drag anywhere on the canvas to drop a moving gravity well and stir the stars by hand. Crank Stars up to 65,536 if you've got a real GPU, or pull it down if your fans start spinning. Everything is live — change gravity mid-collision and watch the whole system respond.

Is this a real simulation or just an animation?

Real. There's no pre-baked path and no fake force field. Every frame, the actual gravitational force between each star and every other star is computed from their current positions and the result moves them. That's why it never repeats and why small changes cascade.

How many stars can it handle?

From 4,096 up to 65,536, each one a full participant in the all-pairs gravity. The cap is your GPU, not a server. If it stutters, drop the star count a notch.

My browser shows a "needs WebGPU" message.

WebGPU is the capability this relies on. It's in recent Chrome, Edge, Brave, Arc and other Chromium browsers, and in Safari 26 and up. Update your browser, or open the page on a desktop with a dedicated or integrated GPU.

Does any of this get uploaded?

No. There's no account, no backend, no telemetry of your simulation. The physics and rendering happen entirely on your own device.

I build things like this every day.

Senior full-stack engineer, available for senior or contract work, fully remote. See the rest of the lab or get in touch.