Jump to content
  • Advertisement
Sign in to follow this  
Plerion

[OpenGL] Replacing black with transparent

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

Hello everybody!

Ive got a bunch of textures which all have a little "problem". What should be transparent is black. The blacker it is the more transparent it should be. Here is an example
http://www.imagr.eu/up/4c305977398e6_RUNE_B.jpg

I am using OpenGL and i have basically no idea how i can advise the renderer to use black as transparent. Is there a way?

Greetings
Plerion

Share this post


Link to post
Share on other sites
Advertisement
Your choices would depend on exactly what you are trying to render and how you are rendering it. The following blend mode may accomplish what you are wanting.

glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR)

You may also want to consider adding an alpha channel to your textures and using standard alpha blend settings.

Share this post


Link to post
Share on other sites
If you want it to be "the blacker it is the more transparent it is" then just run through the pixels and create an alpha channel where the alpha component is the average of the RB&G components.

Apply the code Drak showed above and enable blending.

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!