Advertisement

Blending particles !

Started by June 27, 2003 05:02 PM
4 comments, last by SirTwist 21 years, 8 months ago
Hey guys ... I got the following problem. I am programming a particle engine. For the particles I use rectangle billboards with a texture on it. The texture is for example a white circle in the center with the rest of the bitmap being black. Now with the blendfunc(gl_src-alpha, gl_one) and depthmask(false) that works just great. The particles blend together making up nice color effects like fire, fog and whatever. On a black background, that is !!! And there´s the problem. If I change the background color to white (for example), nothing is to be seen anymore. Which is logical, since the background color (1,1,1,1) now colors every part of the particle in white. Now I don´t know how I can get it to work with every background color without switching of blending, which I need to create those fire effects and stuff ! Any idea anybody ?? I´d appreciate any help here. It´s part of my diploma thesis !! Cheers Twist
Some time back there was a similar question.

I dont think there is a way where u can prevent the particles from blending with the background but blend with other particles at the same time.

One solution i heard of is to render to a texture, and then map the texture to a big quad to display it and change the blending parameters to remove the black areas.
Advertisement
Maybe the drawing-order can fix it? i mean, drawing the particles first, unblendend, and then draw the background blended? or something like that
Errr... Well, first of all; try using Alpha in your billboard texture. Instead of making the area around the circle black, give it a transparent Alpha value. That way, when the scene background is black, the area around the circle is black. When the scene background is green, the area around the circle is green.

As for white particles with a white scene background: yup, you won''t see a thing, quite logically White particles on a white background you can''t see. Just like a grey sheep in dense fog. You won''t see it. What you can do though, is perhaps not make every particle the same color? O_O
Isn''t this what masking is for? Nehe has a great tutorial on it.

--He who laughs last, thinks slowest.
Without order nothing can exist - without chaos nothing can evolve.
Hey CyberSlack .... thanks for that. I looked into the tutorial and it might just be, that this is indeed what I needed.
After the first look it does, at least !!

I like this forum !!

Cheers

Twist

This topic is closed to new replies.

Advertisement