When I was preparing presentation and workshop about particles, I've decided not to write my own code for the system but use some external library.

SPARK Particle Library. I have my 'own' particle system and maybe in the near future I will share the code ( here is a post from the future ). For my classes I wanted to show students how to use third party code and quickly develop some interesting effects. While searching for the library, I found a very interesting piece of software:

Basic description

Example code

Performance

Conclusion

Let's go

Description

Lib version: 1.5.5

Spark is a cross platform particle lib build written in C++ (OO with heavy use of STL) and designed to work well with OpenGL, SFML and Irrlicht.

It is quite low level so when one decides to use it some facade should be added.

Particles simulation is performed on the CPU side only (and then transferred to the GPU only for rendering)

Rendering is done using fixed function pipeline unfortunately (but will change probably in th second version of the library) Structure: System is a collection of Groups - it is optional, because each group can be handled independently if you want.

is a collection of Groups - it is optional, because each group can be handled independently if you want. Group is a core object in the simulation.

is a core object in the simulation. contains Model (description of particles)

(description of particles)

contains particles array (in thing called Pool )

)

and there are some Emitters and Modifiers

and Renderer is connected with a group

Examples

void init() { createModel(); createEmitter(); createGroup(); createRenderer(); createSystem(); } void update() { particleSystem->update((float)deltaTimeInSeconds); } void render() { particleSystem->render(); }

pm = SPK::Model::create(SPK::FLAG_RED | // state of SPK::FLAG_GREEN | // particle SPK::FLAG_BLUE | SPK::FLAG_ALPHA | SPK::FLAG_SIZE, SPK::FLAG_ALPHA, // what mutable SPK::FLAG_GREEN | // what random SPK::FLAG_SIZE); // alpha is mutable from 1.0 to 0.2 over the lifetime of particle // is is interpolated linearly pm->setParam(SPK::PARAM_ALPHA, 1.0f, 0.2f); // green and size are random pm->setParam(SPK::PARAM_GREEN, 0.0f, 1.0f); pm->setParam(SPK::PARAM_SIZE, 0.2f, 4.0f); pm->setLifeTime(7.0f,8.0f);

SPK::SphericEmitter* pe = SPK::SphericEmitter::create(...); pe->setZone(SPK::Point::create(SPK::Vector3D(0.0f,0.015f,0.0f))); pe->setFlow(350); pe->setForce(1.5f,1.5f);

Performance

(i5 2400, Radeon 5570) Rendering: Quads, with texture on 200 000 particles and 50 000 flow: 43 FPS (picture 1) 1 000 000 particles and 100 000 flow: 12...14 FPS (picture 2) 2 000 000 particles and 200 000 flow: 5..6 FPS (picture 3) for the last test I got around 15 FPS when switched to basic PointRenderer

picture 1

picture 2

picture 3

Conclusion

ease of use (in several minutes you have something working)

very nice documentation

ability to extend the particle system by own classes and techniques

performance is quite decent

fixed pipeline rendering (but it should change in second version of the library)

Last version is from 2009... support and development could be a bit faster :)

Source code with my sample: spark_155_particles.cpp

The simplest way to create an effect:Model:Model is quite flexible structure. You can choose what is enabled, what is randomized, what is linearly interpolated over the time. You can even provide custom interpolator for given parameter.Emitter:Creation of an emitter is quite simple. There are several types of this class: like Straight, Random, Spherical.After creation of model and emitters you need to create group(s) and attach emmiters to group. Then attach group(s) to system.For more source code look at attached examples.Of course there are many factors that influence the results, but all in all I think that the performance of this library is quite decent. For effects with millions of particles I suggest using something else (simulation should be than computed on the GPU rather than on the CPU), but for common effects is is quite enough.What I like:What I dislike:

One demo from the library (not mine, official)

Links