Jump to content
  • Advertisement
Sign in to follow this  
ahlywog

Making a certain color in a texture 'clear' ?

This topic is 3550 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

Subject pretty much sums it up. Say I want all black pixels in a texture to be clear. How do I go about doing that? Thank you for your time.

Share this post


Link to post
Share on other sites
Advertisement
What you want is color keying. For the most part, color keying is not hardware accelerated, and generally textures are preprocessed to remove keyed transparency pixels before being submitted to the GPU. Doing this on the GPU in hardware with a pixel shader is super easy and fast as well.

Check out the color keying sample on this page:

http://www.codesampler.com/oglsrc/oglsrc_4.htm


Hope that helps!
~Graham

Share this post


Link to post
Share on other sites
Quote:
Original post by ahlywog
Subject pretty much sums it up. Say I want all black pixels in a texture to be clear. How do I go about doing that?
If the colour you wish to be transparent is either of black or white, than you can play with the blending modes, and come up with some form of additive blending that will do the trick.

For arbitrary colours, you can either generate an alpha channel manually, to match the locations of the colour, or you can use a shader, along with either the 'discard' keyword or a palette texture.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!