PDA

View Full Version : Texture combiners and adding RGBA textures



markfcsl
07-31-2002, 07:05 AM
Suppose I have an RGBA texture in texture unit 0, and another RGBA texture in texture unit 1 (this one has a lot of alpha=0).

I want to add the RGB values of the two textures, but keep the alpha of the texture in unit 0, using multitexturing.

From what I remember reading, you can't just use the GL_ADD texture environment since RGBA textures will cause the alphas to be modulated. So I went over to use the following combiner setup for texture unit 1:

glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD );
glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE );
glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE );
glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB );

But this gives the same result as using GL_ADD, the modulated alphas.

Am I missing something? I've checked this on a GeForce4 and a Radeon 8500, giving the same result in each case.

Cheers,


Mark

markfcsl
07-31-2002, 07:19 AM
Oops, just spotted a dodgy looking GL_BLEND texture environment occurring later on in the code. All my fault.