What is a particle system?
A system which manages the simulation of several individual particles. Where each particle has several properties including but not limited to: position, velocity, color, age etc. Each particle has a set lifetime during which it spawn, updates it’s properties and dies.
Example of a particle system:
Commonly used approaches to implement particle system:
- CPU based particle system: In the approach all the work such as spawning, updating and killing particles is done on the CPU. After these calculations are complete a buffer containing particle data is copied to the GPU.
- CPU/GPU hybrid: Here part of the work is done on the CPU; such as killing and spawning particles and the remaining calculations are done on the GPU. This could be updating particle motion and colors.
- Pure GPU: GPU performs all particle calculations.
For my demo I decided to write a particle system using the third approach i.e., Pure GPU.
Here I used two compute shaders to perform the bulk of the calculations required by the particle system:
- The first compute shader initializes each particle. Sets up initial values for each of the particle’s properties.
- The second compute shader updates these properties for all alive particles. The velocity is updated using the 3D noise function and the position of the particle is updated this velocity.
Link to GitHub repository: CLICK HERE!