PDA

View Full Version : Blend Problem



epsxk82
10-21-2010, 03:30 AM
http://farm4.static.flickr.com/3527/4627518705_2eac742ecc.jpg
Using textures above, i'm making a explosion particle effect.
But now i have got stuck in a problem. I set the two arguments of glBlendFunc as GL_ONE, GL_ONE so that overlapping parts among particles gets lighter. But except that all exsiting pixels in frame buffer are black, color of particle effect is deferrent from what i want because of the blendmode i set(in case of drawing partlce effects on white background color, outputs are white).
Now i consider all partcle effects are drawn into FBO before being drawn into frame buffer. But i think that's not sensible idea cosidering performance. Is there any other solution or any other feasible way using blend functions?

Alfonse Reinheart
10-21-2010, 09:54 AM
But now i have got stuck in a problem. I set the two arguments of glBlendFunc as GL_ONE, GL_ONE so that overlapping parts among particles gets lighter.

Why do you want that?

Unless you're doing HDR rendering, additive blending is not going to give good results. And if you are doing HDR rendering, having a "white background color" doesn't make sense.

epsxk82
10-21-2010, 10:42 PM
SO is there any solution to make flame/smoke effect? Basicaly, to render flame/smoke effect realistically, overlapping parts among particle textures in a viewport should be rendered lighter. So i add dest color and source color.

ZbuffeR
10-21-2010, 11:26 PM
Flame is added light.
Smoke is filtered light.

So you need a blend that is able to do both.

Use premultiplied alpha !
http://home.comcast.net/~tom_forsyth/blog.wiki.html#[[Premultiplied%20alpha]]
glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA);