Software Engineer
Loading posts...
Feel free to contact me at kanishksachdev@gmail.com
Real fluids are governed by the Navier-Stokes equations, which are famously hard to solve. Jos Stam's trick, from Real-Time Fluid Dynamics for Games, was to trade a little physical accuracy for a solver that is unconditionally stable and fast enough to run every frame. That is what is flowing below.
Drag across the canvas to inject dye and shove the fluid around. Pick a preset for a different personality, or open the advanced knobs to play with the raw physics.
The fluid lives on a coarse grid (each cell tracks a velocity and a dye density). Every frame the solver runs the same three moves, then the result is upscaled with smoothing so the low-resolution grid reads as soft, organic flow.
Because the backward advection step trades some accuracy for stability, this is not a physically exact fluid. But it captures the essentials, the swirls, vortices, and buoyant plumes, while staying cheap enough to run every single frame in your browser.
Based on Jos Stam's Real-Time Fluid Dynamics for Games.