This is a particle simulation built in C++ using Raylib for a university assignment. We were required to implement the simulation on the CPU and on the GPU to be able to compare the performance gain.
I structured the data into a SoA layout to reduce cache misses and used instanced rendering to reduce rendering overhead. For the GPU implementation I used compute shaders. Each step runs as a separate pass, this applies for both simulation types. The results are fed into the instance renderer, either straight from the GPU or uploaded from the CPU.
Additionally, we were assigned another project that required building an MMO server with physics integration. To cut down on the implementation time, I created DLL based API, which I then used in the MMO Server
- CMake 3.20 or higher
- MinGW 15.2.0 or equialent
- Raylib
- GLM
The dependencies are downloaded by CMake (FetchContent)
git clone github.com/Rocco2300/particle-simulation
cd particle-simulation
mkdir build && cd build
cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release
cmake --build .
You can now run the project with the following command:
./particle-simulation.exe <mode>
These are the controls:
- Z - to lock/unlock camera
- C - add an impulse to all the particles
- X - add particles
Where you can replace mode with:
--gputo simulate the world on the GPU--cputo simulate the world on the CPU
