![]() |
![]() |
This application is an implementation of a 3D boids simulation. Each boid is represented by a wireframe of a tetrahedron and is enclosed in an aquarium. User can add box obstacles and adjust the following parameters in real time:
- Separation: steer to avoid crowding local flockmates, Alignment: steer towards the average heading of local flockmates,
- Cohesion: steer to move towards the average position (center of mass) of local flockmates,
- View radius: determines the radius of a sphere containing all visible boids by every boid,
- Noise: determines the amount of random acceleration applied each frame,
- Minimum speed,
- Maximum speed.
User can reset the simulation with different aquarium size, boids count and choose one of the following algorithms:
- CPU naive algorithm,
- GPU naive algorithm,
- grid based GPU algorithm in the 1st variant,
- grid based GPU algorithm in the 2nd variant.
Both 3
and 4
algorithms are based on a grid approach with sorting, which is described here (page 6).
The difference is that algorithm 3
capitalizes on the fact that many boids within a singular thread block, are within the same grid cell. To speed up the boid acceleration update process for these boids sharing a cell, shared memory is used. Conversely, Algorithm 4
overlooks this observation.
All 3 GPU methods speeds are compared on the following graph:
The conclusion drawn from the above graph is that the theoretical observation used for algorithm 3
is slowing the algorithm down.
- Use
W
,S
,A
,D
to rotate the camera andQ
,E
to zoom in/out. - Use
Simulation
window to- restart the simulation with different aquarium size, boids count and algorithm,
- modify the simulation parameters in real time,
- add box obstacles.
You need NVIDIA CUDA GPU to run the application. This application has been tested on the following GPU's:
GPU | Memory | Compute Capability |
---|---|---|
NVIDIA GTX 1650Ti | 4GB | 7.5 |
NVIDIA GTX 1060 | 3GB | 6.1 |
NVIDIA GTX 1070 | 8GB | 6.1 |
NVIDIA RTX 3070 | 8GB | 8.6 |
In order to compile the project you need to download and install NVIDIA CUDA Toolkit and CMake first.
- Clone the repository to the desired location
git clone https://github.com/migoox/boids-simulation
, - Navigate to the cloned directory and run
cmake .
, - Run
make
.
- Clone the repository to the desired location
git clone https://github.com/migoox/boids-simulation
, - Navigate to the cloned directory and run
cmake .
, - Open
boids_simulation.sln
using Visual Studio, - Set
boids_simulation
as the Startup Project (right click onboids_simulation
and chooseSet as Startup Project
), - Compile using Debug/Release mode.