DirectX 12 GPU based Particle System

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:

source: wikipedia

Commonly used approaches to implement particle system:

  1. 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.
  2. 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.
  3. 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.
Particle Struct

First compute shader: initializes particle data

Second compute shader: update particle data

Link to GitHub repository: CLICK HERE!

Demo: Renders 10 million particles with additive blending enabled.
%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close