Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

VanKurt

Transparency - Not like it should

This topic is 6197 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!