GPU-accelerated real-time fluid simulation — inject dye and watch vortices form
This simulation solves the incompressible Navier-Stokes equations in real time using your graphics card. Every frame, the GPU performs advection, pressure projection, and diffusion across a 256×256 velocity field — thousands of tiny fluid calculations happening simultaneously.
Click and drag to inject colored dye and velocity into the fluid. Watch how vortices form, interact, and gradually dissipate through viscous diffusion.
Presets
Vorticity measures the local spin of the fluid — the curl of the velocity field. Red regions rotate clockwise, blue regions rotate counterclockwise. Notice how vortices often come in pairs of opposite sign.
In incompressible flow, pressure is not an independent variable — it's determined entirely by the requirement that the velocity field remains divergence-free. The pressure field shown here is the solution to a Poisson equation solved every frame via Jacobi iteration.
Compare high-viscosity fluid (like honey) with low-viscosity fluid (like water). High viscosity smooths out velocity gradients quickly, suppressing small-scale structures. Low viscosity allows thin filaments and intricate vortex patterns to persist.
High Viscosity (honey-like)
Low Viscosity (water-like)
The simulation implements Jos Stam's “Stable Fluids” algorithm (1999) entirely on the GPU via WebGL fragment shaders: