How this WebGL fluid simulation works
This WebGL fluid simulation solves incompressible flow on your GPU every frame. Velocity lives on a grid 128 cells across the short side of the canvas, and dye lives on a finer grid of up to 1,024 cells, so the motion stays cheap while the color stays sharp. Each frame runs these steps in order:
- Add force and dye where your mouse, finger, Auto drift, or music pushes the field.
- Measure local spin (curl) and push it back into the flow, which is the Swirl slider.
- Measure divergence, the places where the flow would bunch up or thin out.
- Solve pressure with 20 Jacobi iterations and subtract its gradient, so the flow stays incompressible.
- Carry velocity and dye along the flow (advection), fading each by the Flow fade and Fade speed values.
- Draw the dye with optional shading, bloom, and sunrays.
The full explanation, with what each step looks like on screen, is in how WebGL fluid simulation works. The physics behind the steps is in what is fluid simulation.
What the fluid simulation can do
The fluid simulation runs entirely in the browser tab. The table lists each feature, what it does, and its keyboard shortcut.
| Feature | What it does | Shortcut |
|---|---|---|
| 8 presets | Classic, Water, Fire, Ink, Calm, Smoke, Aurora, and Neon change fade, swirl, force, and palette | 1 to 8 |
| Mirror | Repeats strokes as a reflection or 4, 6, or 8-way kaleidoscope | M |
| Auto drift | Paints the canvas hands free with two wandering brushes | A |
| Paint on hover | Paints with mouse movement alone, no click needed | H |
| Screenshot | Saves a PNG at screen size (at least 1920 px) or 4K | S |
| Record | Saves a video of the canvas, up to 3 minutes | R |
| Music and Live sound | Moves the fluid to a song from your device or to your voice | None |
| Copy link | Shares your preset, quality, Mirror, and Auto drift as a URL | None |
Every control is described in the fluid simulation controls guide.





