Some advice on a miniB3D particle system

BlitzMax Forums/MiniB3D Module/Some advice on a miniB3D particle system

The r0nin(Posted 2007) [#1]
I have been working with volumetric smoke (which I have been simulating with meshes, etc.) as opposed to sprite-based smoke. MiniB3D has been a dream, but too many smoke trails quickly bring my system to a crawl (and I have a Core Duo system with a decent Vcard). I implemented an array to recycle particle declarations/memory, and got a little bit of a boost. I quickly decided that a much better method of creating meshed smoke would be, instead of creating 150 different copies of the same mesh (which is what I was doing before with lists of meshes), I should load the mesh only once, and then draw it to the backbuffer at multiple places. That way I would only need to store one mesh and then use an array, map, etc. to store positions and orientations where that image would be copied. Unfortunately, miniB3D does not directly allow this kind of operation.

Based on my reading of the miniB3D code, the TCamera.Update method clears the backbuffer for the next draw. So any attempt to draw a single mesh multiple times from outside code would be lost as soon as Renderworld is called. The best option that I can see at this point would be to modify miniB3D itself and create a new function to read and render my smoke (but I'm not sure how to handle z-buffer sorting, if OGL doesn't do so automatically) that I include after cam.Update in Renderworld.

Is there an easier way to do this (I have the sneaking suspicion that I'm missing something fairly obvious)? I know there are particle systems already out there, but I'm interested in this as a learning experience as much as a practical solution. Anyone have any suggestions how to draw a single mesh multiple times at different places in one frame... or even a better way to do this?


klepto2(Posted 2007) [#2]
First you should know that MiniB3D doesn't have a proper detection if something is in view or not (in fact this has to be set by using MeshCullradius(mesh,1) ) . Also you may read some tutorials about singlesurface rendering.

Its late overhere ;) , so i will post tomorrow a bit more.


simonh(Posted 2007) [#3]
Drawing the same mesh multiple times would not give you a speed boost. In fact it would be the same as creating one mesh, then using copyentity on in it many times.

The best way to get a speed boost is to limit the no. of times that OpenGL draws something - so instead of making it draw a mesh 150 times, if you can try and group some of the meshes together somehow, and get it to draw less times you will get a speed boost.

Meshes for smoke sounds excessive though, I don't think you even get that in AAA games! My advice for a super-fast particle system would be to look into using a single-surface sprite system, there is quite a bit of discussion about these for Blitz3D.


bradford6(Posted 2007) [#4]
Check this out. some good info on squeezing better performance out of openGL:

http://developer.apple.com/graphicsimaging/opengl/optimizingdata.html


The r0nin(Posted 2007) [#5]
Thanks guys! I've done some searches on this site and on the web, and while there's a lot of discussion about SSS, I haven't found anything that explains how to do it...

BTW, since miniB3D TSprites are children of TMesh, it doesn't do me much good to use them instead, correct? Same amount of overhead?

I'm still looking for single surface tuts, as well as other options. My main focus is on smoke trails...


klepto2(Posted 2007) [#6]
Try this: http://www.dc.chat-blitz.de/devilengines/Tutorials/Particles.html


The r0nin(Posted 2007) [#7]
Awesome! Thanks klepto2!