View Full Version : When to use the GL_BLEND texture function...

03-26-2002, 10:31 PM
Ok, so after reading the appropriate section of the Red Book I now think I understand how the GL_BLEND texture function works and now I find myself asking what it's good for. I figure this means that I either a) am just plain wrong about how it works, which is why I don't understand when to use it or b) really just don't know when to use it http://www.opengl.org/discussion_boards/ubb/wink.gif

It turns out that GL_MODULATE does what I expeded GL_BLEND to do, and GL_BLEND (if the internal format of the texture is GL_RGB) computes each color as C = C_fragment * (1 - C_texture) + C_envcolor * C_texture according to my copy of the Red Book. What I don't get is why the (1 - C_texture)?!? I mean, all this seems to do is give me negatives of my textures, which I'm having a tricky time figuring out how or why to use.

The situation doesn't seem to be any better when using GL_BLEND with any of the other internal formats, except for GL_ALPHA which seems to make sense (but is also identical to the behaviour using GL_ALPHA and GL_MODULATE).

Maybe somone could help shed some light on this?

03-27-2002, 10:50 AM
Someone must know...

03-27-2002, 01:31 PM
Think of it like this:
The texture color blends between the incoming fragment's color and the constant color. Maximum texture intensity yields the pure constant color, minimum yields the pure incoming fragment color.

If you want something a bit more intuitive (and IMHO much more useful), take a look at the INTERPOLATE function, defined in GL_ARB_texture_env_combine, and also documented in the GL1.3 spec.

03-27-2002, 01:45 PM
Ah ha! I think you illuminated the dark spot for me... GL_BLEND doesn't make sense unless you set the constant color to something reasonable. It still seems a little weird with an RGB or RGBA texture, but that's ok. Thanks!