PDA

View Full Version : How to use a texture's transparancy?



Theo
12-23-2000, 09:04 PM
I am drawing some textures on screen, and I want to use their alpha value. They were loaded as a texture with an alpha (I've visually tested this to be true with glAlphaFunc).

How can I do it? I've tried glBlendFunc but it seems to be ignoring the texture alpha.

Rob The Bloke
12-26-2000, 11:24 AM
You should just be able to use :

glBlendFunc( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );
glEnable( GL_BLEND_FUNC );

If you want to make use of the textures alpha channel once it has been drawn to the frame buffer, you can use :

glBlendFunc( GL_DST_ALPHA , GL_ONE_MINUS_DST_ALPHA );

Only use this however if your 3d hardware supports an alpha channel ( very few do... )

Deiussum
12-27-2000, 06:11 AM
You might get better results if you
glEnable(GL_BLEND);

rather than
glEnable(GL_BLEND_FUNC);

http://www.opengl.org/discussion_boards/ubb/smile.gif

drumminj
12-27-2000, 09:40 PM
It may also be important to get the right texturing mode(GL_TEXTURE_ENV_MODE, I believe)...whether you're using GL_REPLACE, GL_MODULATE, GL_DECAL, etc. These affect how it calculates the alpha value for the current fragment(based on the texture's alpha and the fragment's alpha as per the current state).

J