Particle system - not enough particles due to frame rate

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!
esaptonor
Posts: 145
Joined: Sat May 06, 2006 11:59 pm

Particle system - not enough particles due to frame rate

Post by esaptonor »

in my game i have my fighter units have a particle system when they move, like homeworld fighters, but the frame rate can not go above 60, and that causes problems because no matter what number i put for min and max particles per second, i get this effect

Image

the particles are ment to form a solid line, but they are seperated because my fighters move too fast.
How can i make it a smooth line without just increasing the particle size?
Is it even possible?
Anteater
Posts: 266
Joined: Thu Jun 01, 2006 4:02 pm
Location: Earth
Contact:

Post by Anteater »

If it's just a straight line, just use the draw3DLine() function.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

To do what you want you'll have to write your own particle emitter. The emitter would need to know where the particle system was positioned. It would emit particles between the previous position and the new position so that they are evenly spaced and slightly overlapping.

Travis
esaptonor
Posts: 145
Joined: Sat May 06, 2006 11:59 pm

Post by esaptonor »

dam it, I thought that might be the case but i was wishing for a magical solution. ah well, i guess i had better go and make this thing.
Thanks a lot.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

The first thing you could try is to use a ParticleBoxEmitter with a large box size. Increasing the boxsize will distribute the particles over a larger area and maybe this will already be enough to avoid those gaps.

Otherwise it could even get a little more problematic as you don't have the necessary information (positions) within the particle emitters. So you will have to change the CParticleSystemNode itself. The best place would probably be in CParticleSystemSceneNode::doParticleSystem where the new particles are accessible directly after they are spawned. Check if they are global (it's only of interest for those), remember the old position of the node and interpolate somehow between the old and new position.

Actually i tried that also, but didn't get such good results by that. In my experience about 200 particles per second need to be spawned to get a smooth trail no matter how much you interpolate it (for particles as small as needed for a similar looking trail).
jAyTeA
Posts: 36
Joined: Wed Sep 06, 2006 7:50 am
Location: Hattorf am Harz, Germany

Post by jAyTeA »

have you tried to disable vsync?
That all sounds to me like you have enabled it!
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

The trails in homeworld are made up of joined segments of elengated quads, not individual points or billboards. To get anything like the same effect, you'd have to use hundreds of billboards per craft.

It's not something that Irrlicht supports natively, so you'll have to DIY it.

You could use either flat planes that rotate around their Z axes to face the camera (an exercise for the reader), or cross-polys. Each time the craft changes direction, you need to start a segment, and you'll want to fade the tail segments off over time.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Someone else implemented that in their space fighting game that was in the project forum not too long ago, so possibly you could check that out!
Image Image Image
esaptonor
Posts: 145
Joined: Sat May 06, 2006 11:59 pm

Post by esaptonor »

ok thanks guys, i will try the cross poly thing
esaptonor
Posts: 145
Joined: Sat May 06, 2006 11:59 pm

Post by esaptonor »

Ok i have a new problem, how do i fade out a .3ds animated mesh scene node? That is what i am using for my particles now, it is set to EMF_TRANSPARENT_ADD_COLOR and i tried setting the ambient, diffuse, and emissive colors all to 0 but it remained visible. I can not figure out how to fade it out.
Somehow a particle system fade out affector does it...but looking at the code there all it seems to do is change the color values like i did.

I did a search and found some old stuff on having to use emf transparent vertex alpha, i would prefer not to use that...but do i have to? is there a way to easily set the transparency of a scene node?
And this has to be done on dozens of scene nodes every frame...so is using the mesh manipulator to change the vertex alpha very draining on performance?


thanks,
esaptonor
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

There might be another way to do it, but i'm also using EMT_TRANSPARENT_VERTEX_ALPHA and set all the alpha values.
I think EMF_TRANSPARENT_ADD_COLOR is using the texturecolors, so you would have to do texturemanipulations at runtime when using that. Sounds slow...
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You're saying that each of those little greenish boxes is an animated mesh scene node [instead of a regular particle sprite]? That is probably why your performance is bad.

Travis
esaptonor
Posts: 145
Joined: Sat May 06, 2006 11:59 pm

Post by esaptonor »

no the boxes were particle sprites.
I started trying to make a new one with animated mesh scene nodes (just 2 quads in a cross) because it was easier than creating the quads via code, but then of course i couldn't change the transparency, so now it is all done with code, and i can change the transparency when my new scene node is rendered, so it is all perfect!

And i have had good performance...the frame rate is locked so it can not go higher than 60 frames per second, and the only time it ever went below 59/60 is when i first added my asteroids...and each group had over 10 thousand polygons in it, so of course the scene suddenly had over 100 thousand polygons and the frame rate dropped, but i fixed that easy enough by creating new meshes, and since then performance has been good.
So in short, i dont understand the performance comment.

To sum up: It all works now, thanks for all your help! :)
Mloren
Posts: 114
Joined: Mon Aug 07, 2006 2:30 am
Location: Australia
Contact:

Post by Mloren »

why would you want to lock your framerate?
esaptonor
Posts: 145
Joined: Sat May 06, 2006 11:59 pm

Post by esaptonor »

My map has inconsistancies in it, ie, there is more asteroids in some places than others, and so when you are scrolling around, the amount of polygons on screen can suddenly increase a lot. If vsync is off and i let the frame rate go high anyway, then it can change from 200 down to 80 when some asteroids come on, and this makes things less smooth. It also takes a second or two for irrlicht to get the correct frames per second, so my ships can suddenly slow down for a split second, which just makes things look jerky and less professional (in my opinion).
So to make it all nice and simple i just lock the frame rate to 60. That way all the small changes in frame rate are not a problem.
Post Reply