PDA

View Full Version : Transparency



RML
10-18-2003, 02:44 AM
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" ?

Tom78
10-18-2003, 03:49 AM
What kind of BlendFunction do you use ?

cu
Tom

RML
10-18-2003, 03:57 AM
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 ?

10-18-2003, 06:44 AM
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.

gvm
10-18-2003, 08:29 AM
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);

RML
10-18-2003, 10:17 PM
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 :-)

RML
10-20-2003, 08:47 PM
it worked. now i used tga with alpha. there was no problem with it. thanks :-)

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

gvm
10-21-2003, 01:50 AM
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).]

RML
10-21-2003, 07:04 AM
yes that i mean. i will look for this :-)