PDA

View Full Version : Decaling with GL_ARB_multitexture



Frumpy
03-21-2001, 07:00 PM
I am testing decaling with GL_ARB_multitexture. I have a base texture with an all white alpha layer. I have a decal texture with white at the symbol and black else where in the alpha layer.

Using the old fashion multipass method I would
disable depth test
glBindTexture( base texture )
glTexEnv( ,, GL_REPLACE )
draw quad

enable alpha testing
glBindTexture( decal texture )
glTexEnv( ,, GL_REPLACE )
draw quad again

However a similar approach doesn't seem to work with multitexturing.
disable depth test
glActiveTextureARB( unit 0 )
glBindTexture( base texture )
glTexEnv( ,, GL_REPLACE )

glActiveTextureARB( unit 1 )
enable alpha testing
glBindTexture( decal texture )
glTexEnv( ,, GL_REPLACE )

draw quad including glMultiTexCoord*
disable alpha testing

Now all I see the decal and no base texture. I suspect pixels from the base texture made it past unit 0 but got discarded by unit 1 because either the pixel was:
a) under the decal and got overwritten or
b) located at a point where there was a decal alpha value of zero and failed the alpha test.

What's the way around this while still using multitexturing?

zed
03-21-2001, 08:11 PM
try GL_MODULATE instead of GL_REPLACE

Frumpy
03-21-2001, 11:18 PM
No go with GL_MODULATE but GL_DECAL did work. I thought GL_REPLACE and GL_DECAL did the same thing but I guess not.

Thanks for the suggestion tho.

j
03-22-2001, 08:37 AM
GL_REPLACE and GL_DECAL aren't the same. With GL_REPLACE, the current texture replaces all of the color information from the previous texture, including alpha. GL_DECAL blends the current texture in with the previous texture based on the alpha channel, which is why it works for you.

j