Speeding up custom particle engine -> reducing draw calls

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Gorbstein
Posts: 37
Joined: Wed Nov 25, 2009 8:44 pm
Location: Scotland

Speeding up custom particle engine -> reducing draw calls

Post by Gorbstein »

Hi,

I decided to make my own particle engine for my game from scratch, since I wanted some unusual custom functionality. All works well except it is very slow.

My explosion effect uses 6 emitters which give a total of about 30 or so particles on-screen at the peak of the effect. Not many, yet at this point my app drops from about 180FPS to 30FPS. See FPS in titlebar:

Image

Have ruled out the system code since it stays at 180fps if I just do node->setVisible(false) on all particles.

I think the problem is my amount of draw calls, since I'm using a scene node for each quad/particle. Yes, this is bad, but I'm not 100% familiar with the best way to do this in the irrlicht pipeline.

Since I have lots of independently moving quads with changing scale, rotation and material (colour+alpha) properties, what is the best way to render these in the irrlicht pipeline for performance?

D
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

Well i had the same problem but my particle engine is alot faster...

http://irrlicht.sourceforge.net/phpBB2/ ... p?p=244651
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
pippy3
Posts: 155
Joined: Tue Dec 15, 2009 7:32 am

Post by pippy3 »

I've read irrlicht has a lot of complexity issues when it comes to particle effect algorithms.

While it makes sense to write a new particle engine, why not simply patch irrlichts to your desire?

then you can release it and help everyone else.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

pippy3 wrote:I've read irrlicht has a lot of complexity issues when it comes to particle effect algorithms.

While it makes sense to write a new particle engine, why not simply patch irrlichts to your desire?

then you can release it and help everyone else.
well didn't i just do that?
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Gorbstein
Posts: 37
Joined: Wed Nov 25, 2009 8:44 pm
Location: Scotland

Post by Gorbstein »

Sudi : how did you overcome the problem? Do you use scene-node per particle or another way of combining all independent particles into one scene-node / draw call?

How does irrlicht batch the particles together in its own particle engine?

I thought about writing a custom scenenode which sorts all quads added to it by texture to reduce texture switches, but I read that Irrlicht does this automatically anyway?

I can't use mesh batching because each quad has independent position/alpha/colour, or am I wrong here?

Part of the problem I'm sure is my crappy laptop which only has a Intel915GM (basically like a Geforce2) but other particle engines I've tried (such as SPARK or irrlicht's own) on the same hardware run at about 10k+ particles before slowing down, so I'm still doing something wrong.

Pippy : The reason I didn't want to patch Irrlicht's is that A) this is my very first game and I want to learn the insides, and B) I want to remain fairly engine independent. I've written the game engine so that most of the graphics calls are quite generic and at this moment I could easily plug it into OGRE or something else. I want to stay with Irrlicht though.

D
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

Well mine basicly works like the irrlicht node. particles are not scenenodes...which is really just a big waste of time. i batch particles of the same type of a particle node into one draw call. so basicly the explosion you see in my project announcment thread has 7 different effects and therefor 7 drawcalls. this could be reduced further and i will do that actually.
But yeah incase your goal isto use a working particle solution for irrlicht that supports what ya need maybe just using mine is a good idea.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Post by REDDemon »

you can update easily thousands of quads in real time and compute their coordinates(on the CPU) for make them looking to the screen or to something else and still get a Framerate of 300+.

Need only few meshbuffers for that. If you can iterate all the quads in a single loop there will be a great performance increase. Of course you lose the chance to attach them to a scene node.

If you want to attach them you have to get AbsolutePosition (wich is computed). and then add it to quads that belongs to that scene node.

Well you have also to compute particle modifiers (so color,position scaling) and that's can be a bit more long.

thousand of particles at 300+fps is better than 30 particles at <60 fps
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
Gorbstein
Posts: 37
Joined: Wed Nov 25, 2009 8:44 pm
Location: Scotland

Post by Gorbstein »

Thanks all. OK, I'm starting to see now.

I don't need the functionality of scene nodes, it just seemed a convenient way to get stuff on the screen easily. I don't even need culling - I do that myself anyway - and there aren't going to be many big explosions outside the player view anyway.

Sudi: I had a look at your code in CParticleDrawer and I see what you're doing.. using big vertex buffers to hold all particles in each effect and refreshing it with everything (colour, position, relevant indices) every frame?

This makes sense to me. I think will be able to abstract the Irrlicht part from my engine as well by writing my own VertexBuffer class which just expands to hold enough particles as needed and is refreshed every frame, then all sent to the card using one draw call.

I suppose using a single texture atlas I could do every particle in my engine in one draw call...

8)

D
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Re: Speeding up custom particle engine -> reducing draw c

Post by bitplane »

Gorbstein wrote:I think the problem is my amount of draw calls, since I'm using a scene node for each quad/particle.
Why not use the particle system scene node? It doesn't batch across multiple nodes, but it will be a lot faster than using one per particle.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Re: Speeding up custom particle engine -> reducing draw c

Post by sudi »

bitplane wrote:
Gorbstein wrote:I think the problem is my amount of draw calls, since I'm using a scene node for each quad/particle.
Why not use the particle system scene node? It doesn't batch across multiple nodes, but it will be a lot faster than using one per particle.
bc the irrlicht particle scenenode only supports billboard particles....
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Post Reply