Particle System Performance
#1
Posted 21 November 2009 - 04:19 PM
Right now i can throw about 600 into my game world before the frame rate starts dropping off below playable levels. It's not heavily optimized, or multithreaded yet, running on a 2.6 GHZ cpu and in a debug build. Adding collision detection to the particles perhaps drop totals down closer to 200.
#2
Posted 21 November 2009 - 04:32 PM
Also you can try some particle systems on GPU (with help of geometry shaders it is really easy and damn fast ... adding collision detection on GPU is on the other hand a bit tricky).
If you don't know how to speed up application, go "roarrrrrr!", hit the compiler with the club and use -O3 :D
#3
Posted 21 November 2009 - 04:39 PM
The GPU is another story though. That is dependant on how much the particles overlap. Remember that every visually overlapping particle is another large batch of overdrawn pixels. Try to make sure that the particles are not stacked on top of eachother. If you need thick smoke, make them more opaque rather than adding more. This is something that just takes a lot of area/level polishing. I don't know of an elegant tech solution to this.
EDIT: oh, and it may seem trivial, but make sure that the particle data is always passed by reference or pointers (unless this absolutley can't be done). You would be stunned at how much of a speed difference this makes.
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
#4
Posted 21 November 2009 - 06:21 PM
#5
Posted 21 November 2009 - 06:41 PM
This game is an experiment into component based design, and i've changed the method which looks up components so that it uses a simple array instead of std::list<> which has huge implications for performance across the app. This change in storage method plus adding an inlining at least doubled the total supported particle count.
Here's how it looks now.
inline GameComponent *component(ComponentID pID)
{
return m_Components[pID];
};
I also went into my rendering code, fixed a somewhat ill conceived sprite-rendering function which had both a cast from float-to-int and then from int-to-float on each sprite coordinate, and perhaps achieved better batching by calling D3DXSprite::begin() and D3DXSprite::end() only once per frame instead of on once a per-particle basis. (Does anyone know whether these methods actually govern when the data is sent to GPU?)
My latest weapon is a 600 particle flame type projectile, which the game can render about 3 in debug, and a continuous stream (screenshot must contain about 6000) in release builds with the mentioned optimizations.

I do desperately want to avoid optimizing too early though, as we all know premature optimization is evil.
EDIT: After some additional testing i can unleash 20 of these into a release build at once before performance drops, making for a total of 12000 particles. That number drops down to (perhaps a generous) 1800 particles (or 3 projectiles) with collision detection enabled.
#6
Posted 21 November 2009 - 07:13 PM
SmokingRope said:
In closing, I am not the best programmer, nor anywhere near that level, so take my advice with a grain of salt. Fellow programmers, if I am mistaken tell me, but in the same light, if I am correct tell me as well. Thanks
#include <arcade>
#include <computer>
#include <drinks>
#include <hardware/high_end>
#include <snacks>
#pragma <responisiblities>
...........
#7
Posted 21 November 2009 - 07:40 PM
#8
Posted 21 November 2009 - 08:21 PM
There are some optimizations I know will be effective in my sweep and prune algorithm i've decided to put off simply because they won't yield much benefit with the current scene complexity.
#9
Posted 22 November 2009 - 09:27 AM
#10
Posted 22 November 2009 - 06:16 PM
JarkkoL said:
That was the point of this question more than looking for advice on how to optimize my particle system.
What numbers have you seen an indie or triple A game set for particles in a scene?
I appreciate the numbers given by starstutter and TheNut however if others could provide similar feedback on their engines, and past projects it would give a more appropriate sample size for determining how adequate or inadequate the performance of my own (and others) particle systems are.
#11
Posted 23 November 2009 - 12:32 AM
#12
Posted 23 November 2009 - 01:41 AM
#13
Posted 23 November 2009 - 05:08 AM
#include <arcade>
#include <computer>
#include <drinks>
#include <hardware/high_end>
#include <snacks>
#pragma <responisiblities>
...........
#14
Posted 23 November 2009 - 06:26 PM
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
#15
Posted 23 November 2009 - 08:24 PM
#16
Posted 24 November 2009 - 02:15 AM
#include <arcade>
#include <computer>
#include <drinks>
#include <hardware/high_end>
#include <snacks>
#pragma <responisiblities>
...........
#18
Posted 24 November 2009 - 09:50 AM
JarkkoL said:
-
Currently working on: the 3D engine for Tomb Raider.
#20
Posted 24 November 2009 - 10:02 AM
JarkkoL said:
Depends on the game.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












