Simple generic particle system

A basic openGl particle system. It lets the user simulate a maximum number of texture size square particles in realtime. View Source Code



Features:

·The system can handle multiple emitters for creating particles at each update step
·Process birth around emitters and death after random life time
·Update positions with a global (position-invariant) force
·Stop vertical movement at a ground plane
·Can also display a texture cube, force directions and emitter positions for debug
·at first i planned to do a renderman dso to read particles but writing to exr directly is probably the way to go instead



When running the program right click in the window to get the option menu.
See the Readme.txt for all display and simulation options.

This is not a full state preserving simulation as velocity is not stored.
Also local forces and collision objects are only modelled on cpu yet.



Implementation:

The system uses frame buffer objects, GLSL shaders and floating point textues to simulate and render the particles.
Particle birth and death have to be separately calculated on CPU and GPU so that unused particle indices can be reused. The particle positions and some attributes per particle are uploaded to a texture and then updated inside a fragment GLSL shader. Static particle attributes are only updated for new particles on the cpu.
The result is render back to a texture offscreen. At drawing the position textures are "re-interpreted" as vertex data.
All data has to be double buffered and is ping-pong drawn by two fbos with the help from texture coordinates stored in a vertex buffer object.


A screen shot of the running program

Resources

The following pages helped me to develop the code:

I plan to add some of the missing features (velocity, collision, different render types, more user control) in the next weeks and update the code.

Download:





particle system

using openGl fbo
home