Particle system

From DmWiki

A particle system is a group of particles - usually small sprites - used to model phenomena like clouds, vapor, fire, splashing water, sparks, explosions, and other volumetric effects.

You can organize the functionality of a particle system into the following:

  • Particle emitter: Creates new particles as needed
  • Particle updater: Updates each particle and removes (kills) the ones no longer needed
  • Particle renderer: Renders the particles to the screen

A particle structure can have any number of properties defined within it. Each property would control a different aspect of the particle; for example, a life property could define how long the particle lives, or a size propery could define how big the particle is. Other properties could include position, velocity, color, energy, or whatever is needed. Typically, the particle emitter will create particles with properties randomly distributed over some range. Randomness makes particle systems appear more natural and realistic. The particle emitter itself may have additional properties that determine the rate at which particles are emitted and the range of their initial properties. It is also possible to have multiple emitters within a single particle system.

The particle properties usually change over time, and this is the job of the particle updater. For instance, a fire particle might start out as a white color, then fade to yellow, red, and eventually black before dying. The updater also controls particle motion. The simplest kind of motion would just be for the particle to travel in a straight line, possibly affected by gravity or drag. More complex motion could involve the particles attracting or repelling each other, or colliding with geometry in the world.

Rendering particles can be tricky. Very often, they are rendered as billboards, which give the appearance of a small round shape that looks the same from any angle. More complex particles can have irregular shapes, in which case they would need to be represented as an axial billboard or a model.

Particles are often transparent, and rendering transparent objects requires special care. See transparency.

See also


DevMaster navigation