A 2D fluid simulator running entirely on the GPU with OpenGL compute shaders, built by ShaderGruppa at Hackerspace NTNU. The goal is a Position Based Fluids solver (Macklin & Müller, 2013), later extended toward multiphase and gas behaviour (Macklin et al., 2014).
Status: work in progress. The repository currently contains the compute-shader harness (window, GL context, shader loading, ping-pong SSBOs); the PBF solver itself is being built on top of it.
- A GPU and driver supporting OpenGL 4.6 (macOS is not supported — it stops at 4.1)
- CMake ≥ 3.20 and a C++17 compiler
- Ninja (recommended)
- Git (GLFW is downloaded automatically at configure time; GLAD is vendored in
external/)
Windows: MinGW-w64 (e.g. the one bundled with CLion).
Linux: sudo apt install build-essential cmake ninja-build libgl1-mesa-dev xorg-dev
git clone https://github.com/hackerspace-ntnu/pbf-simulator.git
cd pbf-simulator
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build
cd build
./pbf-simulator # pbf-simulator.exe on WindowsThe build copies shaders/ next to the executable, and the program loads shaders by relative path. Always run it from the build directory.
Open the folder as a CMake project. In the run configuration, set Working directory to $CMakeCurrentBuildDir$.
- The compute shader to run is set by
shaderNameinsrc/main.cpp. - A shader named
foo_render.compautomatically gets a matchingfoo_update.comprun each frame on the ping-pong buffers, if one exists. - Hold the left mouse button and drag to rotate (for shaders that use
uYaw/uPitch).
- M. Macklin, M. Müller. Position Based Fluids. ACM TOG 32(4), 2013. doi:10.1145/2461912.2461984
- M. Macklin et al. Unified Particle Physics for Real-Time Applications. ACM TOG 33(4), 2014. doi:10.1145/2601097.2601152