CPE 471 Final Project -- Particle System Implementation by Chad Williams, Fall 2010

Introduction

For my final project in CPE 471, in preparation for CPE 476++ next quarter, I decided to design a component that would be helpful in constructing the game I work on. The component that I settled on was a particle system class due to the amount of visual richness it can add to a game. Since I had already written a such a system during my internship with Cadenza Interactive, I decided to port the C# code (using XNA/DirectX and WPF) I had developed to C++/OpenGL/wxWidgets. Thanks to Matt and Spencer at Cadenza for allowing me to do this!

Implemenation

The particle system follows a very clean class structure, allowing very easy integration into any game using OpenGL. Each system is composed of individual particle emitters and particle affectors. Multiple affectors can be added to each emitter, and multiple emitters can be added to each system. Each affector and emitter have many properties that can be changed, and can be updated dynamically while the game is running by accessing and modifying the appropriate properties. Furthermore, I integrated the changes that Spencer made with regards to instancing — each particle system and emitter can be instanced to increase performance.

Particle system structure

To further increase performance, all particle physics, and other miscellaneous tasks such as billboarding, are done on the GPU with GLSL shaders. The end result bypasses the fixed-function pipeline completely, allowing complete control over the appearance and behavior of the particle system. This relieves the CPU to only handle particle generation and passing off the data to the GPU. To further increase performance later on, a switch from immediate mode rendering to something like vertex buffer objects (VBOs) would help. The only reason VBOs were not implemented for this project was due to time. Performance is still very good though, even on a low-powered laptop with an Intel integrated graphics chip, displaying a particle system with many thousands of particles.

For the UI aspect of the project, wxWidgets was chosen over other OpenGL-friendly UI implementations such as GLUT and SDL due to its flexibility. However, wxWidgets was not at all easy to deal with and came with hours upon hours of work just to get it to compile, so the resulting UI unfortunately does not have much functionality with regards to tweaking the active particle system in the display. The entire UI was designed, but I did not have time to implement the event handlers that change the particle system (some aspects of the system CAN be controlled, just not ALL). The user is able to zoom and rotate around the particle system in the viewer, and the FreeImage library was used to enable loading PNG files (so nice alpha-blending additive effects can be achieved).

Controllable Properties

Particle System Instance
  • Position
  • Scale

Particle Emitter
  • Emitter Name
  • Emitter Type (Point, Box, Circle)
  • Emitter Enabled
  • Particles per Second
  • Burst Enabled
  • Loop Burst
  • Burst Amount
  • Start Time
  • Particle Start Color
  • Minimum Scale
  • Maximum Scale
  • Minimum Particle Lifetime
  • Maximum Particle Lifetime
  • Minimum Initial Velocity (X, Y, Z)
  • Maximum Initial Velocity (X, Y, Z)
Color Fade Affector
  • Target Color
  • Fade Type (Linear, Quadratic, Cubic, Smooth Step)
  • Fade is Inversed

Gravity Affector
  • Gravity Strength

Swirl Affector
  • Swirl Speed
  • Swirl Plane (XY, YZ, XZ)

Move Affector
  • Enable Move X
  • Enable Move Y
  • Enable Move Z

Screenshots

Magic System
Smoke System
Sparks System

Complete UI

Resources