03 FLUIDS/

STABLE FLUIDS

Real-time fluid simulation with vorticity, turbulence and visual feedback.

Fluids: dithered still of the stable fluids scene

03_fluids/readme.md

Approach

A classic Stam-style stable-fluids solver on a 2D grid: advect, add forces, project. Each step is its own compute pass over ping-ponged textures, and the pressure solve runs a fixed number of Jacobi iterations so the frame cost is predictable.

Techniques

  • Semi-Lagrangian advection with a MacCormack correction to keep the ink filaments sharp instead of smearing after a few seconds.
  • Vorticity confinement re-injects the small-scale swirl that numerical diffusion eats, which is where the marbled texture comes from.
  • Dye feedback — the ink density is fed back into the forcing term at a low gain, so the flow slowly organises itself into bands.

What to look at

Drag across the frame to stir it. The wide aspect ratio is deliberate: the flow has room to develop long shear layers before it wraps around.