The project consists in implementing a disintegrating mesh particle effect
- Drawing the mesh to the main framebuffer but discarding fragments that have a value lower than a (gradually increasing) threshold on a mask texture
- Draw the mesh but only the discarded fragments to a separate off-screen framebuffer
- Read the off-screen framebuffer on cpu and spawn particles at the position of the discarded fragments
- Update particles
- Draw particles with instancing
Install git and cmake
Install build tools for visual studio and check optional during installation:
- msvc v143
- c++ cmake tools for windows
- Windows 10 sdk
Open cmd with "Launch" in visual studio build tools 2022 or from start "Developer powershell for VS 2022" and in the root folder of the project run:
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg; .\bootstrap-vcpkg.bat -disableMetrics
cmake -DCMAKE_BUILD_TYPE=Release --preset=default
cmake --build .\build -- -j 10To not build the benchmark executable add -DBUILD_BENCHMARK=OFF to this cmake command:
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_BENCHMARK=OFF --preset=default- Ubuntu
git cmake g++ libglfw3-dev libassimp-dev libglm-dev libbenchmark-dev- Fedora
git cmake g++ glfw-devel assimp-devel glm-devel google-benchmark-devel- Debug build
cmake -DCMAKE_BUILD_TYPE=Debug -G "Unix Makefiles" -S . -B ./cmake-build-debug
cmake --build ./cmake-build-debug -- -j 10- Release build
cmake -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" -S . -B ./cmake-build-release
cmake --build ./cmake-build-release -- -j 10To not build the benchmark executable add -DBUILD_BENCHMARK=OFF to this cmake command:
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_BENCHMARK=OFF -G "Unix Makefiles" -S . -B ./cmake-build-releaseModels and textures can be added respectively to assets/models and assets/textures and will automatically appear in the menu after a restart of the application
RTGP-Project [width] [height]- Run the program with a custom resolution (without arguments defaults to 1920x1080)
Esc- Toggles the menu on and offR- Resets the simulationP- Pauses the simulationMouse- Moving the mouse while the menu is closed moves the model on the XY plane
- Change model and texture
- Change mask texture used to make the model disappear
- Rotate and scale the model
- Particle control (max number, size, speed, lifetime, direction, movement randomness)
The executable Benchmarks-RTGP-Project runs all benchmarks
To run a subset of benchmarks: --benchmark_filter=<regex> Benchamark library docs
Note that running all the benchmarks sequentially can result in a crash on some configurations (Linux/AMD, not on windows). Running the single benchmarks does not result in a crash.
List of benchmarks:
- BM_UpdateParticles
- BM_SpawnParticles
- BM_SpawnAndReplaceParticles
- BM_DrawParticles
- BM_CopyFrameBuffer
- BM_ReadFrameBuffer
- BM_Pipeline_Step_1
- BM_Pipeline_Step_2
- BM_Pipeline_Step_3
- BM_Pipeline_Step_4
- BM_Pipeline_Complete
- Inspiration for this project Disintegrating Meshes with Particles in 'God of War' GDC 2019 Talk
- Particles and instancing
- Render to texture
- PBO
- Opengl guides
- RTGP Course material
- Credits to Screaming Brain Studios for most of the noise textures
