Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 9 of 9

Thread: Transparency

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2003
    Posts
    8

    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" ?

  2. #2
    Intern Contributor
    Join Date
    May 2003
    Location
    Cologne / Germany
    Posts
    58

    Re: Transparency

    What kind of BlendFunction do you use ?

    cu
    Tom

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2003
    Posts
    8

    Re: Transparency

    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 ?

  4. #4
    Guest

    Re: Transparency

    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.

  5. #5
    Intern Contributor
    Join Date
    Feb 2003
    Location
    Mitishy
    Posts
    59

    Re: Transparency

    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);

  6. #6
    Junior Member Newbie
    Join Date
    Aug 2003
    Posts
    8

    Re: Transparency

    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 :-)

  7. #7
    Junior Member Newbie
    Join Date
    Aug 2003
    Posts
    8

    Re: Transparency

    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 ?

  8. #8
    Intern Contributor
    Join Date
    Feb 2003
    Location
    Mitishy
    Posts
    59

    Re: Transparency

    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).]

  9. #9
    Junior Member Newbie
    Join Date
    Aug 2003
    Posts
    8

    Re: Transparency

    yes that i mean. i will look for this :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •