Simple Smoothed Particle Hydrodynamics fluid simulation using compute shaders.
Simulation based on this whitepaper on SPH fluid sim.
Visualization based on an old GDC talk done by Simon Green on screen space fluids.
This should not be taken as a learning source, as the code is rather messy, not to mention there are quite a few optimisations that are missing.
sph_fluid_h264.mp4
Make sure to get the submodules after cloning the repo
git submodule init
git submodule update
Then build as usual using cmake
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j n # Here n should be something like <core count> + 1
This will produce a binary sph_fluid_sim
that you should be able to run. Make sure you run it from the build directory, as the shader source and cubemap images are hardcoded as relative paths!
Make sure you have GLEW on your system, as well as X server related libs, mainly: libxrandr, libxinerama, libxcursor.
- This could really use a nearest neighbour optimisation in the simulation code. Some ideas on how to do that can be found here.
- Normal recalculation doesn't seem quite right, needs looking at.
- There are some weird grid-like artifacts that needs investigation.
- Overall screen space fluid rendering needs optimisation.
This project is licensed under MIT License - see LICENCE file for details.