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.
I've also added 160,000
Lagrangian
particles on top of the simulation -
these particles are rendered using
threejs, but their positions are
computed on the GPU.
Instructions: Click and drag to apply a force to the fluid. Over time, the colored material in the fluid will
dissipate: