Fluid Simulation Shader
This simulation solves the
Navier-Stokes equations for incompressible fluids in a GPU fragment shader.
I implemented
no-slip boundary conditions at the borders to keep the fluid contained within the bounds of the screen.
To increase performance, I solved for the velocity vector field of the fluid at a lower resolution than I used to compute the visualization of fluid flow; I used bilinear interpolation to smooth out artifacts caused by this speedup.
Instructions: Click and drag to apply a force to the fluid. Over time, the colored material in the fluid will dissipate.
I found the following sources helpful while writing this simulation:
Real-time ink simulation using a grid-particle method - a method for real-time simulation of ink
in water using a coarse-grained fluid simulation with a particle simulation on top.
Fast Fluid Dynamics Simulation on the GPU - a very well written tutorial about programming the Navier-Stokes equations on a GPU.
Stable Fluids - a paper about stable numerical methods for evaluating Navier-Stokes on a discrete grid.
By
Amanda Ghassaei, code on
Github.