Particle

Blitz3D Forums/Blitz3D Programming/Particle

Landsrad(Posted 2003) [#1]
Good day.
Why not include a paricle function in B3D?
Or perhaps there is but i don't see it...


Rob Farley(Posted 2003) [#2]
Every particle system is unique and optimised to work with a specific game, Sswift has a particle system you can buy, and there a couple in the code archives for nothing. Or indeed write your own and optimise it for your project.


Landsrad(Posted 2003) [#3]
Thanks for reply :o)


jhocking(Posted 2003) [#4]
That is pretty much true but most particle systems work in essentially the same way. I don't think I've ever seen someone write/use a particle system which was a radical departure from the way other people do them. Just as the built-in collision detection is great for most purposes (you only need to code your own custom collision system for really obscure/specific purposes) I think a built-in particle system (which would cover the needs of most people) would be really useful. Ultimately however I don't think the time spent implementing that would be worth taking away from all the other things on Mark's plate right now.


big10p(Posted 2003) [#5]
Hmmm, I think you have to leave *something* for the programmer to do. Writing particle systems is actually quite good fun, IMO :)


RetroBooster(Posted 2003) [#6]
jhocking:
"That is pretty much true but most particle systems work in essentially the same way. I don't think I've ever seen someone write/use a particle system which was a radical departure from the way other people do them. Just as the built-in collision detection is great for most purposes (you only need to code your own custom collision system for really obscure/specific purposes) I think a built-in particle system (which would cover the needs of most people) would be really useful. Ultimately however I don't think the time spent implementing that would be worth taking away from all the other things on Mark's plate right now. "

Although it may be true that most particle systems are quite alike and creating a generic particle system that is usefull for most people is quite possible, there are huge differences in complexity and preformance between many particle systems, some games need only simple effects and might be covered with simple single surface particle emitters which spray from a point based emitter with fluctuation, while particle stats only include things like startalpha,endalpha,startsize,endsize,minspeed,maxspeed,lifetime and some other basic data like coordinates, I can't be bothered to write you up a type right now.

Other games however, like my current titles have far different needs, my most functionaly advanced particle system supports features such as:

Any type of particle, be it: a whole mesh, a sprite or even a single surface particle emitter
Particle acceleration/deacceleration control during lifetime
Particle path following
Dynamic particle collision settings supporting things such as death on impact and bouncing
Magnets and repulsors
Tons of different emmision shapes, from point, to plane, to sphere, to cylinder, yielding such wonderfull effects as rings of fire, particle explosions etc.

This allows me to put together particles and emitters that preform almost any feat imaginable, be it a person completely built from particle effects, a tornado of whirling particles, massive colorfull explosions, the same explosion followed by the particles forming any kind of shape, such as letters or even a whole model, etc.

Although this is realy cool I doubt some of the simpler titles would ever use all this functionality, in which case it's much better to build a small custom system rigged for preformance, then using such a big prefabricated system of which you won't use 1/10'th of the features.

So to put it shortly, even if a built in particle system would meet all that and maybe advanced particle flocking while we are at it ;) It would still not be optimal for every project, yet if it would be simplified and basic it would not be optimal for the larger projects. Basicaly, your better off building what suits you... Plus it's a ton of fun!


gellyware(Posted 2003) [#7]
My first project is to build a particle system, problem is... Its hard to find out how :) Ive begun the basic steps...and its fair to say, i successfully made a sprite that moves :) ... Does anyone have any recommendation on where to get information about creating a particle system, or esentially what is the logic behind them? Even though Im new to blitz I have been programing in flash 5/mx for a 1.5 years now, so this feat is not impossible for me :) i just dont know the logic behind it. Anyone?


Ricky Smith(Posted 2003) [#8]
The code archives has quite a few good examples of particle systems.
Sswifts particle system is no longer available.


Landsrad(Posted 2003) [#9]
Thanks to all the repliers :o)


HNPhan(Posted 2003) [#10]
i recommend that you use 1 surface particle system for the best speed, but since your just new to particle system, i guess it could be abit hard for you, but you could try if you really wanted to, heres a demo of a single surface particle system that i created not too long ago:

http://www.blitzcoder.com/cgi-bin/showcase/showcase_showentry.pl?id=tigerz06112003211532&comments=no


jhocking(Posted 2003) [#11]
Single surface is faster but there are specific reasons you might not want to do that. Among other things that can create problems in draw order; alpha transparency doesn't work with the z-buffer and particles often use alpha transparency. This isn't a huge problem (since situations where draw order becomes important are fairly rare for particle systems) but definitely something to keep in mind.

This is why in my particle system I did what RetroBooster did and support both single surface and sprite based particles. Usually single surface is better because it is faster but occasionally I need to use sprites for particles due to draw order problems.


gellyware(Posted 2003) [#12]
very interesting! ok I will give single surface a shot, And I suppose if I could do single surface, sprite conversion wouldnt be hard?


gellyware(Posted 2003) [#13]
Tigerz, do you have any sample code for downloading? Or do you protect it with your life? :) Some reason winzip isnt working so i cant download the demo yet.


HNPhan(Posted 2003) [#14]
Jhocking, are you sure thats the problem only arises when using single surface particle? i think i remember having the z-order problems even when using multiple surface particle. But if your gonna use Mask texture or using ADD blending mode, then you wouldnt have that problem.

Bombone, no sorry, i dont have sample code to share, try downloading WinRar, its better IMO


jhocking(Posted 2003) [#15]
Oh no, the problem doesn't only arise with single surface. The problem is due to alpha transparency and will arise any time you use alpha transparency. However the problem is worse with a single surface particle system since, without z-buffer, the drawing order is based on entity distance. And in a single surface particle system the entire particle system is a single entity, resulting in it either being entirely in front of or entirely behind other alpha entities. That last point also gets at what I meant when I said that problem situations are rare; it only matters if you have something with alpha transparency inside the particle system (eg. a character with alpha hair walks through the smoke.) In most situations in games it is okay to treat the entire particle system as a single entity.


big10p(Posted 2003) [#16]
However the problem is worse with a single surface particle system since, without z-buffer, the drawing order is based on entity distance


So, don't alpha'd entities get rendered through the z-buffer, then?