Jump to content
  • Advertisement
Sign in to follow this  
tomba

how to do alpha and masking at the same time?

This topic is 4728 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, i have a file called hero.bmp, hero_mask.bmp (2D sprites). The second of is the mask i used for transparent image. This works fine, but i also want to combine alpha with this image. currently i am using glBlendFunc(GL_DST_COLOR,GL_ZERO); glBlendFunc(GL_ONE,GL_ONE); for transparency texture. how do i combine alpha and transparency at the same time? i tried using GL_SRC_ALPHA ,GL_ONE_MINUS_SRC_ALPHA with glColor4f, but i get images that have alpha but not transparent. Basically I can get alpha and transparent to work separately but not together.

Share this post


Link to post
Share on other sites
Advertisement
Try:

glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

also you can use alpa testing to remove all pixels with a alpha below (or above) a given value, like this:

glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GEQUAL,0.1f);

The code above will make all pixels with an alpha value of less than 10% insvisible.

Share this post


Link to post
Share on other sites
remember ALPHA_TEST doesnt draw to the depth buffer but GL_BLEND does so if something is 50% transparent it will oclude that which is behind it if your rendering order is incorrect

Share this post


Link to post
Share on other sites
thx for the help guys, but i found out that it can be done very easily if used tga files rather than bmp. so prob solved. :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!