tranparent textures

Started by
5 comments, last by dadio 22 years, 8 months ago
I want to texture a quad with a tree image. How do I set the ''non tree'' part of the image to be transparent? thx
Advertisement
Use the ALPHA channel from 32-bit textures. Or ALPHA blending wich I don''t personnaly recommend...
sorry, but can I get a more specific explanation...
I think he means to use alpha testing, you give your image an alpha channel and then makle the bits you want for example 1 and the bits you dont want 0.
Then enable GL_ALPHA_TEST (I think thats it), and use glAlphaFunc();(again I think thats it) to set up the parameters so it for example only only renders the texels where there alpha is 1. this wy the rest wont be draw.
Look up those functiuons and it should be come clear, hope I got the names right.
What you need to do is make a 32 bit targa with a transparent background (GIMP and Photoshop are the best for that... and GIMP is free: http://www.gimp.org), and then do this inside your program:

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//now render the images

------------------------------
Trent (ShiningKnight)
E-mail me
Shining Darkness- A division of Chromesphere Studios
quote:Original post by Seaman
I think he means to use alpha testing, you give your image an alpha channel and then makle the bits you want for example 1 and the bits you dont want 0.
Then enable GL_ALPHA_TEST (I think thats it), and use glAlphaFunc();(again I think thats it) to set up the parameters so it for example only only renders the texels where there alpha is 1. this wy the rest wont be draw.
Look up those functiuons and it should be come clear, hope I got the names right.


Pretty much, that''s what I did.

glAlphaFunc(GL_GREATER, 0.3f);
glEnable(GL_ALPHA_TEST);

~ Dragonus :D
The way I like to do it is to have my images created with a full alpha channel, and saved as a .png. Then rendered with per-pixel alpha from the texture''s alpha channel. This does the trick nicely, and you can blur the edges of he alpha channel in photoshop, resulting in some fake edge antialiasing.

This topic is closed to new replies.

Advertisement