Particle System Optimisation Help Needed

Hi There,
Been thrashing at this for some time now and could really use the help.

I have an ofxPD project that runs well on an iPad 2 but sluggishly on an iPad air 2. Good on non-retina, bad on retina.
Removing antialiasing in alleviates the issue as does disabling retina, but i think this is just treating the symptoms, not the problem.

Im not sure whether the way i have formed this project is good practice or not.
The format is like this:

in ofApp:

partSys particleSystem;

in particleSystem:

vector<Particle> particles;     // 1500 of these get made as circles (i resize the vector to 1500 before i create them)
vector<Bolt> bolts;            //these only get created when theres an interaction
vector<Blobage> blobs;         // one gets made every 600 frames and gets erased soon after

in Blobage:

vector<Shard>shards;     //200 of these are made when one of the blobs gets created, again i resize the vector before i create them.

All of these (apart from particleSystem) are created, updated and drawn in for loops, the framerate lowers instantly after ofApp::setup

Im using this structure to create the particles in their vector:

void partSys::createParticle(int z) {
Particle p;
p.pos.set(ofRandom(width), ofRandom(height));

Theres a for loop in partSys::setup which calls createParticle(int from for loop)

I setup, update and draw the particleSystem from ofApp with this style of syntax:


Do i need to start looking into threading? or should i be wearing the dunce hat?
Any help would be hugely appreciated


As with most optimization stuff the devil is in the details but I would look at:

  • Creating a pool of bolts up front
  • Reusing blobs instead of erasing them

Allocation is often the easiest bottleneck to spot/measure

Thanks for this, it was really useful. The optimisation has definitely helped
Strangely enough it turned out that it works beautifully on all iPads including the iPad Air, but grinds to a halt on the iPad Air 2

For other people coming across this -

OF 9 has sorted out the sluggish speed on iPad air 2 (I assume this is because of 64bit architecture)
Also big thing that I found for drawing particles - it seems much more efficient to use pushMatrix() and pullMatrix() to draw offscreen rather than on screen so…

DO -


Hoping to stop some sore heads :slight_smile:

a trick that I do to have efficient particle systems with circles is to use an ofMesh with mode set to OF_PRIMITIVE_POINTS and call


this way I draw all particles at once which is much better then calling ofCircle a bunch of times.
It’s quite efficient and simple, saves you from going to the trouble of making a geometry shader or use transform feedbacks.

Ahhh ok, thanks for the info. Do they look good with a radius of 10 or 20 pixels? Or is it just for smaller particles?

with glEnable(GL_POINT_SMOOTH) they look good with very big particles (i’ve used 100 pixels).
Try and see!

cracking! will do, thanks