Transparency

hi,
i just want to make some parts of a polygon complete transparent (cliping ?).
my problem is, that the transparent parts are always a little bit darker than the background. is this normal ? cant i get rid of the “shaddows” ?

What kind of BlendFunction do you use ?

cu
Tom

hi,
first i enable BL_BLEND;
then DepthFunc(GL_LEQUAL);…
glDepthRange(0,1);
glEnable(GL_DEPTH_TEST);
glBlendFunc(GL_DST_COLOR,GL_ZERO);
glBindTexture…
then i paint the first quad

then i change the

glBlendFunc(GL_ONE,GL_ONE);

and paint the next Quad on the same position.

after that i disable the Blend and DepthTest.

if it is important: i use loaded “tga” and its on a 2D environment.

is there something wrong with it ?

Hmm. It appears you are trying to mask out all the black pixels in the texture. If that’s the case, make sure your tga file is in fact using black, and not using alpha transparency. If it is using alpha transparency, then either using an alpha test (instead of the blending) or fix the file.

glBlendFunc(GL_DST_COLOR,GL_ZERO);
i’m not shure this will work!
glBlendFunc(src,dst)!!!
so maybe this: glBlendFunc(GL_SRC_COLOR, GL_DST_COLOR);
if your texture has alpha channel do this like:
glEnable(GL_ALPHA_TEST);
glAplhaFunc(GL_LESS, 0.5f); // discard all fragments which alpha value is lesser than 0.5
render();
glDisable(GL_ALPHA_TEST);

okay, i’ll try this this afternoon.
the tga is a uncompressed tga. the color is RGB and its “real” black (0,0,0).

thanks :slight_smile:

it worked. now i used tga with alpha. there was no problem with it. thanks :slight_smile:

can anyone tell me how to load tgas or bmps in any size ?

what do you mean in “…load tgas…”?
if you mean load them to gl then:
use gluBuild2DMipmaps to use not square-sized textures
or use glTexImage with GL_TEXTURE_RECTANGLE_NV… or rescale image by hand

[This message has been edited by gvm (edited 10-21-2003).]

yes that i mean. i will look for this :slight_smile: