Archived

This topic is now archived and is closed to further replies.

Particle System Slow-Down

This topic is 5572 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I am making a particle system using texture mapped quads. The problem is that with just over 100 MAX_PARTICLES, the particle system causes a major slow-down to my scene. Does anyone know what may be a major cause for the slow down? What are some of the most known "performance intensive" problems that arise when using particle systems. I am texture binding with GL_MIPMAP_NEAREST_LINEAR (I think, can''t remember exactly) and using blending for the particle system. It is just too slow... My machine and video card are pretty fast for today''s gaming standards. It''s just my particle system that is probably messed up a little. TommyB

Share this post


Link to post
Share on other sites
It''s impossible to tell what the slow down is caused by, first we need your system specs. It probably is your particle system that is screwed up because 100 particles even with all the OpenGL nicest settings should not be slowing down a modern machine.

We might need to see some code if you think it''s your particle system. Are you re-cycling the particles or creating new ones? How are the new ones created if so? So many factors so little code.

Share this post


Link to post
Share on other sites
I am not binding and storing textures per particle. I bind the texture per my set of particles (all 100 of them). I am using a linked list as a data structure to store the particle info and yes I am re-cycling them, not destroying and creating new ones. I should also mention that my particle system is not the only thing "animating" on the screen, I also have a space-ship that is controlled via keyboard that the particle engine is for. I recalculate the new particle positions every single time in the loop.
When I turn the particle engine off, the space-ship moves a lot faster than when the particle engine is on.
I would post some code, but I am not at home right now and don''t have access to my code



TommyB

Share this post


Link to post
Share on other sites
yhou should be more concrete. please post your system specifications along with some bench marks.

how is your frame rate?

try adjusting the size of your particles (if they´re too big, you can really get performance problems on even the fastest GPUS).

Share this post


Link to post
Share on other sites
Pentium 4 1.4 GHz
512 MB RAM
GeForce 3 Video Card

The particles are 0.025x0.025 in size and they are texture mapped.
Do you think that the way I am mapping textures may pose potential problems.
I do not know how to calculate frame rate. I am fairly fresh at this and would appreciate if someone told me how to calculate the FPS.

TommyB

Share this post


Link to post
Share on other sites
First off you may want to implement some sort of performance indicator so you can see how much an effect added systems have on your engine (the easiest being a simple FPS).

Look to see what state changes you are making between particles. Generally performance can be inhanced by limiting the number of opengl states you are making (assuming it actually is the opengl aspect which is slowing you down, for example you have a memory leak of some kind which could be slowing you down).

Sorry, can''t do any more without code

Share this post


Link to post
Share on other sites
particles normally are blended + esp if theyre big this can cause fillrate problems, to see if this is the case make the window small eg 200x150pixels + see if the fps raises heaps if so then youre fillrate bound.
possible helps are enabling alphatesting with greater than 0.0 as well as blending

>>The particles are 0.025x0.025<<

that tells me nothing about there size ie it could mean they cover the whole window or less than 1 pixel.

to calculate fps?
try one of the nehe tutorials or www.gametutorials.com they should have an example

heres a simple way (not guarantted to work )


static int loop=0;
loop++;
if ( loop%50==0)
{
static int last_t;
int t = clock();
printf("%f\n", 1.0/((t-last_t)/1000.0) );
last_t=t;
loop=0;
}

http://uk.geocities.com/sloppyturds/gotterdammerung.html

Share this post


Link to post
Share on other sites
You might want to try creating the particles using triangle strips instead of quads.

I asked one of the Black Robes why the Deceiver wasn''t going to stay to defend the dam, and he tersely replied: "He goes to warn the Emperor; moving through odd angles, faster than any man, and if unobserved, much faster than that."

Elemental Engine: ryan_lurvey.tripod.com/engine.html

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Well just a few notes here for particle preformance.

#1. Don''t calculate the particles camera transform for each particle. Do it for the first particle then use this value and apply it to all the other particles. This should improve preformance quite a bit.

#2. Linked lists aren''t exactly the best to use in this situation, because if you set a particle to "dead" you still have to iterate through it to find the next particles address. A dynamic array that''s calculated on startup should improve preformance a bit. Remember don''t delete your particles just set them to "dead". Dynamic allocations/frees eat alot of CPU time.

#3. Make sure your caching the texture your using for your particles don''t load a texture from a file durring the time your particle systems running only on startup. (yes I know this is a stupid point but you''d be amazed at what people do). File IO is very slow.

Share this post


Link to post
Share on other sites
Well,
I was debating whether I should post this or not - but I decided to do it, so that you guys may have a good laugh at me...
While designing my particle system, I was logging various parameters to a file and completely forgot about removing the logging. It was logging per particle! I removed the logging and the animation literally flies now!
Thanks very much for everyone''s help and I promise not to waste your time next time.

TommyB

Share this post


Link to post
Share on other sites