Particles Engine

Started by
14 comments, last by JavaCoolDude 18 years, 10 months ago
Hello hello , im trying to build my own particles engine ( as some of you suggested ), and i got some questions 1) any *performances" tips is welcome . ANY :) 2) I cant find how the others are getting blending to do what they whant ! ( what i want is -> in the center of my FX ( where there is more aprticles ), it appear ~ white ; i noticed ppl use ( gl_scr_alpha , gl_one ) . but a ) i tried, it doesnt do what its suposed to do b ) it seems to sux if i draw my FX OVER a textured quad . 3) I reaally need some performance adives ;) Thx !!
Advertisement
I personally use additive blending when I try to simulate flames or bright particles, for that glBlendFunc(GL_ONE, GL_ONE) does the trick for me.
I can't think of too many performance tips, if you're using immidiate calls it's time to switch to VA or dynamic VBO's. You can always give the ARB_point_sprite a run and see whether that boosts performance or not (even though it seems broken on certain hardware like when you introduce custom texture coordinates to Radeon 9700s).
Now can you post a screenshot visually describing the "hideous" :D result mentioned in b?
I have other suggestions about building a nice particle engine since I've done the same just few weeks ago, let me know if you need any further help.
Peace dude.
re , (GL_ONE , GL_ONE ) doesnt do the trick for me :)
i seend 2 source of particule engine ( nehe's and a french one ) , both very simple, they use ( GL_SRC_ALPHA , GL_ONE ), i tried taht too ... didnt worked :/
I may me missing something :/

im not familliar with this vocabulary , immediate calls = glbegin(), glend() ?
if yes, yup that's what im using .
I dont know what VA and VOB stand for, but im sure i can find ;) ill check that .

Concerning the FX over my texture, it isnt "hideous" , it's just blending with my texture witch isnt cool ^^ anyway, the pb is the same w/o texture, i cant find the "missing" parameter that blend correctly .

( i.e i want that when their is many particles on the same spot, it does become lighter . )

AS im just starting this , ill certainly need further help :) thx a lot .
stupid question, but are you actually enabling blending? glEnable(GL_BLEND)?
First: you need to enable blending (see above post)

As for Performance: When particles die don't deallocate the memory just flag them as 'dead' and recycle those dead particles to respawn new ones when needed.
NOTE: a simpler particle system might get away with just re-initialising particles that die to avoid the overhead of finding and flagging dead particles.

VA = Vertex array
VBO = vertex buffer object
Both of these can be used to increase performance over immeadiate mode (glBegin and glEnd)

ARB_point_sprite is (likely to be) faster but much less flexible

Why not build your system with the flexibility to choose the blending criteria rather than hard-coding it.
offcourse i have enabeled blending ;) but i cant find a way to get the result i want .

When particles die, i just change their life value from 0 to 1 :) so no reallocations .

ill check VA ; VBO seems a little complicated .
im still lost ;o)
ty anyways
i have an architecturally sound particle system that relies on heavy use of virtual functions if you're interested. unfortunately its not built with performance in mind.

if you want performance don't allocate and re-allocate particles, simple flag them as dead or not.
also use fixed sized arrays (boost::multi_array).

good luck :)
hehe i already said that i flag them :)
and yeah i was using a vector ...forgot that iterator is the slow !
Im using a "normal" tab, with fixe size .
I got 275 fps, ( 200 with vector)-> only 6000 particles .. i have many optimisations to do :p but thats not my first goal :) my first goal is too get those fucking particle to get lighter when their are a lot on the same space .^^

thx anyway :)

edit : can i know more about your particle system ?
see my website below ive been working on a particlesystem designer recently (theres an oldishish screenshot there), u can change the textures/blending etc during runtime which helps u achieve the look u want
* point_sprite is useless (i recently removed it from my game) the only reason u would want to use it is if youre drawing >10,000 tiny particles
*the thing that tends to kill preformance in particles is the overdraw (not the number of particles) this comes cause usually u have depthwrites off, blending on thus the same pixel onscreen can be overdrawn many many rimes, ways of improving this are texturecompression alphatest etc
One possible cause is: To make the particle system go to white as more particles overlap each other, you need the particles to have at least a small amount of each of the R, G, and B components. If your particle was say, red (255, 0, 0) then red plus a bunch more red is still red. But if you have something like (255, 1, 1) then a bunch of those will eventually add to (255, 255, 255).
........................Leo LeeSoftware Engineerhttp://www.leolees.com

This topic is closed to new replies.

Advertisement