Smoke without particle system

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
dawasw
Posts: 357
Joined: Tue Aug 10, 2004 4:39 pm
Location: Poland

Smoke without particle system

Post by dawasw »

Is there any way to make nice smoke effect without particles ?

Because I've noticed that particle systems eat performance a lot and that's why I don't want to use them at all.

(or maybe I'm wrong ?)
Watcher
Posts: 40
Joined: Sat Jul 01, 2006 9:44 am
Location: Czech republic

Post by Watcher »

Maybe you should use a billboard and texture animator.
xtheagonyscenex
Posts: 131
Joined: Fri Jun 03, 2005 7:26 pm

Post by xtheagonyscenex »

or you can use both and have a really nice effect thats what i use it give movement to the particles realism cause it changes textures
"Held in Your arms but too far from my heart." "These thoughts will carry me through the darkest nights...while your eyes rest in mine."
"How quickly I forget that this is meaningless."
sgt_pinky
Posts: 149
Joined: Sat Oct 14, 2006 11:20 am
Location: Melbourne, Australia

Post by sgt_pinky »

(or maybe I'm wrong ?)
I'm surprised you would even post this question before at least experimenting. Seems lazy.
Intellectuals solve problems - geniuses prevent them. -- Einstein
#irrlicht on irc.freenode.net
dawasw
Posts: 357
Joined: Tue Aug 10, 2004 4:39 pm
Location: Poland

Post by dawasw »

Actually I'm not lazy. I had on mind by that system specs. & performance problems.

I have gf6600 gt and when running a program with quite big map; newton and vehicle collision detection + some additional effects + particle effect can make the framerate slower sometimes ;)
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Sorry to drag this thread up a bit, but hes not wrong! The particle system is a bit of a hog. I have my scene at about 60FPS and if i add about 10 particle systems then it drops to less than 30FPS and even lower if more are added... The performance gets better if i release less particles in each system, but then the effect doesnt look as good, so i guess its about a compromise!
Image Image Image
xterminhate
Posts: 206
Joined: Thu Sep 01, 2005 9:26 pm
Location: France

Post by xterminhate »

I can't remember, is Irrlicht using point sprites or just multiple billboard in order to render particules ?
Return to Irrlicht after years... I'm lovin it.
It's hard to be a Man !
Si vis pacem para belum
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

As of right now, Irrlicht uses only billboards. I submitted a patch to hybrid a while back that allows the user to swap in particle renderers. This would make it possible for the user to change how the particles are rendered without rewriting/copying all of the particle system code. I don't know if it will ever make it into a build or not, but I did write it up.

I will say that you can do very realistic looking smoke with very few billboard particles. In my experience, the trick is you have to have a few different billboards [say 4] and each particle has to rotate and scale independently. Unfortunately you'll need to create your own particle system if you want to do any or all of these things.

Travis
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

It seems like a lot of good patches don't make it into svn. I'd suggest that submitting them to the tracker might help to keep them in sight and in mind.

Regarding the performance hit, did you try it in both debug and release mode? I've seen some quite startling differences in performance when performing big loops of basic Irrlicht operations in debug versus release.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I got a nice effect in the end and it only take a performance hit when there's quite a lot on the screen so i think it might be ok. The strange thing i found was that the performance doesn't drop off gradually the more particle systems you add. It just basically drops down from 60 to 30 when you add something like the 10th one :? That's not what i would have expected!
Image Image Image
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

It just basically drops down from 60 to 30 when you add something like the 10th one
It sounds like you're running with v-sync enabled. If so, you should know that the display will only be updated as frequently as your monitor refresh rate, or some common factor of that. So if your refresh rate is 60hz, you can see frame rates of 60, 30, 20, 15, 12, 10, 5, 4, 3, 2 and 1 fps.

Something else to consider is that a particle system is maintaining information for every particle that it creates. If you have 10 particle systems, but 9 of them are way out of sight, you might want to disable them until you are closer.

Travis
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Yeah i've got vsync on due to that icky problem with the disappearing triangles hehe. Without vsync the fps goes much higher. I did wonder why both my main scenes were being rendered at 60fps when one of them was definetly higher before, now i know!

There's also no worry about particle systems running offscreen or anything as i handle all of that stuff, camera never moves in my game and once something goes offscreen it gets cleaned up.
Image Image Image
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

There was some performance problem with particles which was related to allocating and releasing memory. I'm currently not sure if it's still in there. In this thread ( http://irrlicht.sourceforge.net/phpBB2/ ... highlight= ) Pr3t3nd3r did add the erase_fast and push_back_fast functions to get around that problem. I solved it somewhat similar on my own irrlicht version. But there have been a lot of changes to the particles which i haven't merged yet with my local irrlicht, so i can't say much about the current state of that system.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The array<>::erase() method doesn't allocate or deallocate memory, but it would require the particles to be copied from the tail of the array up toward the head as the ones at the front expired. That could get pretty expensive when there are many partlcles. I noticed that change go in, and a day or so later it was yanked.

I did a quick test with the following particle system code...

Code: Select all

// add camera
scene::ICameraSceneNode* camera =
   smgr->addCameraSceneNodeMaya();
camera->setPosition(core::vector3df(0, 0, 800));
camera->setTarget(core::vector3df(0, 0, 0));

scene::IParticleSystemSceneNode* psn =
   smgr->addParticleSystemSceneNode(false, 0, -1, core::vector3df(0, 150, 0));
psn->setMaterialTexture(0, driver->getTexture("media/particlewhite.bmp"));
psn->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
psn->setMaterialFlag(video::EMF_LIGHTING, false);

scene::IParticleEmitter* pe =
   psn->createBoxEmitter(core::aabbox3df(-50, 10, -50, 50, 20, 50), core::vector3df(0, -.1f, 0), 200, 1000); 
   psn->setEmitter(pe);
pe->drop();
The lines of code in question are...

Code: Select all

if (now > Particles[i].endTime)
{
#ifdef FAST_ERASE
   u32 n = Particles.size() - 1;
   Particles[i] = Particles[n];
   Particles.set_used(n);
#else
   Particles.erase(i);
#endif
}
As you can see I added a preprocessor macro to allow me to compile the source both ways, one using the fast erase method and the other using the normal erase method.

With the stock Irrlicht code I get 85 fps in debug and 390 fps in release. If I define FAST_ERASE, I get 120 fps in debug and 370 fps in release. So, as you can see, it does help quite a bit in debug, but in release the fast erase is not really that fast.

Things change if I increase the min/max particles per second by a factor of 10. With the stock Irrlicht code I get 0 fps, and the fast erase code gets nearly 40 fps. That is in release. In debug I get 0 fps with stock Irrlicht, and 10 with the fast erase version.

Travis
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

I just checked my own code and looks like i did it somewhat similar to your solution. The erase_fast for array is definitly no good method.

Code: Select all

      if (now > Particles[i].endTime)
      {
            Particles[i] = Particles[Particles.size()-1];
            Particles.erase( Particles.size()-1 );
      }
I think i did that not so much because of the average FPS, but because it created some peak times when profiling. I remember that it freezed my game in release sometimes 2-3 seconds without that change.
Post Reply