Real-time Position-Based Fluids in OpenCL, homework in Stanford's CS348C
Course assignment for CS 348C: Animation and Simulation, Fall 2016. Based on the paper Position-Based Fluids by Macklin and Müller.
The idea with the cl-gl-bootstrap template is to allow for multiple simulation demos to be run in the same executable. This is accomplished by having multiple "scenes" available on startup. To start the PBF-simulation scene, press the "LOAD" button in the "General Controls" UI pane and select the only available scene.
The UI displays the average time for a simulation frame (not the rendering) in the Scene Controls UI, as well as the current average FPS (which takes into account both simulation and rendering).
Recordings created by pressing the button with the record symbol are exported through FFMPEG and saved as .mp4-files in the /output folder. Beware, the average simulation time will be incorrect when recording (don't know why yet).
To load a specific fluid setup, use the buttons in the interface on the left ("Scene Controls"). The "Fluid Parameters" UI to the right can be used to adjust the fluids properties, and parameter configurations can be loaded/saved using the provided buttons. The provided file "dam-break-3.txt" works well for the fluid setups available currently.
The program has only been tested on MacOS so far, so it will probably not run on Linux or Windows without modifications to the CMake configuration and some parts of the source dode.
The only dependency which is not included in the source code is GLM (which is found by CMake and must be installed on the machine), the rest are included as git submodules.
git clone https://github.com/bwiberg/position-based-fluids.git
git submodule update --init --recursive
cmake -DCMAKE_BUILD_TYPE=Debug ..
and then make
from that directoy (NOTE: the program will crash with the output "illegal hardware instruction" on MacOS if using the release configuration, I will have to investigate why)./pbf
. Optional program flags and arguments are:
-w 1280 720
Opens the window with a resolution of 1280x270.-f
Causes the program to run in fullscreen. Overrides the -w
flag. (NOTE: must specify the -cl
flag when using the -f
flag)-cl 0 1
Automatically selects the OpenCL context as alternative 0 and the OpenCL device as alternative 1.