View Full Version : I still don't get blending.

06-15-2004, 01:10 PM
I understand that you have an alpha value and that it basically represents transparency. I just dont' understand the macros they give you. Why cant you just pass GL_ONE,GL_ZERO to the glBlend function and have an alpha value of .5 and it work?

06-15-2004, 01:45 PM
Your solution may 'work' for your needs apparently.

But glBlendFunc allows a lot of different transparencies, do a search on recent threads about this GL command.

To sum up, you may want additive or substractive transparency, use source alpha or destination alpha to modulate the mix between src and dst, etc. You can render with a film 'negative' effect (very nice for demos, that one), have xor-like operations, use coverage antialiasing, and much more.

06-15-2004, 04:54 PM
Okay I get that, but how come when I enable Depth test and GL_LESS it doesn't work. And my two triangles seem dimmer now?

06-17-2004, 03:35 AM
"It doesn't work" doesn't really give us lots of information. What did you expect to happen? For "standard" blending you generally want glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

The final color is computed as follows:


This is all described in detail in the spec. In your example src_fact is 1.0 and dst_fact is 0 which will lead to a simple replace, no blending. With GL_ONE, GL_ONE factors you get additive blending and my example gives "standard" alpha blending.

EDIT: You also need to draw all transparent primitives last with depth test enable and depthmask set to false, sorted in bacl to front order ifyou want the blending to be correct.