AO

The Particle Fiasco

Screenshot 2026-09-08 032313

Oh this one of the things that I've been wanting to do in a game engine. To make a particle system. There were at least 3-4 attempts of mine doing this, and this latest one just hits that mark.

How does it work?

Oh I stole it from Unity's shuriken system. Well... at least that was the system that I got used to, but I don't really like it. This is built like the shuriken system because I currently confident with the engine's graph system. I do want this to have a graph editor instead of a multiple settings in one because well... it makes more sense moving forward.

The particle system is simulated through GPU. When an emitter is created, it basically tells the GPU to reserve a buffer for the simulation. Each particle has their own specific particle slot in the gpu to reside in and the GPU keeps this until the emitter is not needed anymore.

Since the particles themselves live in GPU, we use compute shader in order to advance the simulation of the particles. The compute shader access the buffer that the particle lives on, and updates their location.

A Particle's Life-cycle

A single particle contains 3 lifecycle events: Birth, Simulation, Death.

Birth

Given that the emitter exists and already had requested the GPU to reserve slots for the particles, it will send how much particle it will need for the frame (at base, it reqests 32 particles per second so that's 32/60fps) CPU accumulates the rate for the frame (as it needs to be a whole number).

Once the acumulation is done, it now updates the input to the GPU buffer.

Simulation

GPU checks if there are any available slots from the reserved particle slot requested by the emitter. If it found one, then it allocates a new particle to that slot and updates the position of that particle.

If GPU wasn't able to find a slot, the creation requests will be dropped. Say if the emitter requires 5 particles to be created during the frame but there are only 2 slots available, it will only simulate 2 additional particles and disregard the rest.

Death

They simply just free the slot that the particle holds for reuse.