A 3D fluid simulation reproducing Jos Stam's Stable Fluids (SIGGRAPH 1999) paper.
Built with ImGui + OpenGL 3.3, featuring volume ray-marching and full simulation pipeline under both periodic and fixed boundary conditions.
Compiled executable files for windows at here.
reference/stam-stable_fluids.pdf
Each timestep follows the paper's order:
AddForce (buoyancy)
→ Advect (semi-Lagrangian, MAC grid)
→ Diffuse (implicit viscosity, Jacobi iteration)
→ Project (pressure Poisson: FFT for periodic, Jacobi for fixed BC)
→ Advect density through divergence-free velocity
- MAC staggered grid: velocity on faces, density/pressure at cell centers
- Semi-Lagrangian advection: trilinear backtracing
- Periodic BC: spectral Poisson solver via 3D FFT (self-implemented radix-2 Cooley-Tukey)
- Fixed BC: Jacobi iteration Poisson solver (replacing FISHPAK from the paper)
- Volume rendering: GPU ray-marching, rainbow density colormap, dual-light shading
- Interaction: left-click injects force + smoke, right-drag orbits camera, WASD to move
- Full UI controls: grid resolution, timestep, viscosity, buoyancy, dissipation, diffusion, etc.
Requires CMake + OpenGL 3.3 + glfw3.
cd build
cmake .. -G "MinGW Makefiles"
mingw32-make
./SF_Reproduction.exeFor better performance, build in Release mode:
cmake .. -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles"
mingw32-make| Input | Action |
|---|---|
| Left-click drag | Inject smoke force |
| Right-click drag | Rotate camera |
| WASD | Move |
| Scroll | Zoom |
| UI panel | Tune all parameters |
- Jos Stam, Real-Time Fluid Dynamics for Games, SIGGRAPH 1999
- This project was developed with assistance from DeepSeek V4