Transparency - Not like it should

Started by
2 comments, last by VanKurt 22 years, 3 months ago
Hi folks ! I want to draw some grass-sprites on the ground. So I have drawn a texture with black borders around the grass, then I looked for the right blending settings so that the black boarders would be invisible. I found em here: From the "OpenGL Game Programming" Book: glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0); glBindTexture(GL_TEXTURE_2D, texture); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); I took a look at the sample that used this this code, and it worked fine. Then I put the code to my app, and it did NOT work ! What happens, is that the whole texture (not only the black parts) gets 50% tranlucent. That''s not what I wanted... :-( What could be the reason for this ? Maybe some other (wrong) settings ? MfG, VanKurt
Advertisement
I suspect, that there is a problem with the alpha channel of your grass texture. Make sure, it has a valid alpha channel, and that the used texture format supports it.
Simple, dont use GL_BLEND whilst using GL_ALPHA_TEST, and your alpha masked areas shouldnt appear.

-----------------------
0wn 0wn 0wn your goat
gently down the pw33n
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
Maxmimus: ??
Of course you can use GL_BLEND in conjunction with GL_ALPHA_TEST, why shouldn''t you ? A fragment is dicarded, if it''s alpha value is within the alpha test range, otherwise it is alpha blended. Where is the problem ?

VanKurt: I''m sure, that there is a problem with the alpha channel of your texture, or that the selected texture format doesnt contain an alpha channel at all.

This topic is closed to new replies.

Advertisement