View Full Version : Use full 8 bits of TGA's alpha channel?

10-17-2002, 03:37 AM
What I'm looking to do is make a texture with the same levels of transparency that I save my TGA files with. They have 8 bits of transparency, but all I've been able to get is Transparent or Not Transparent when I load them as textures and draw using Alpha Testing. I was wondering if there was some way to use the full 8 bits of alpha information in the TGA file for smooth blending?

So if I had a black square with 255 alpha on the right side faded to 0 alpha on the left, it would appear a continuous blend rather than half black, half not, like a glAlphaFunc of GL_GREATER, 0.5 would do.

10-17-2002, 04:18 AM
Sounds like instead of alpha testing, you want alpha blending. Try this:


10-17-2002, 05:31 AM
Yup, that was what I was looking for!

Thing is though, I already had that... It's just that I accidentally had blending and alpha testing enabled, so alpha testing took precedence. Your reply helped me figure that out. I also wasn't sure exactly how blending worked with texture alpha channels because I knew you could specify alpha with a glColor4f call... I'm guessing this could be used as an additional factor in blending? Like the texture alpha value and the color4f alpha value are multiplied? Well, thanks, your post certainly helped me resolve a longstanding confusion I've had (and finally got around to looking into).

[This message has been edited by rhmazza (edited 10-17-2002).]

10-17-2002, 05:48 AM
Yes, you can use the primary color (that is glColor4f) as a secondary factor. Use the texture environment function GL_MODULATE, and the primary color and texture color will be multiplied.