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 3 of 3

Thread: setting alpha to 0 but still see objects?

  1. #1
    Intern Newbie
    Join Date
    Nov 2010
    Posts
    40

    setting alpha to 0 but still see objects?

    Hello,

    I have a vertex shader where I am trying to have the visibility of some terrain fade out at some distance from the viewpoint. I was trying to ramp the fragment color alpha down from 1.0 to 0.0 to do this. That should work, shouldn't it?

    Anyway I notice that even when I explicitly just set the fragment color to 0, the objects are still visible. Shouldn't setting the fragment color w value to 0 make it invisible?

    Thanks
    Bob

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    Shouldn't setting the fragment color w value to 0 make it invisible?
    No. Alpha doesn't mean anything by itself. It's just a number. It only takes on a meaning based on what you do with it. If you want alpha to make something transparent or transluscent, you will need to employ blending and key the blend function off of the alpha.

  3. #3
    Intern Newbie
    Join Date
    Nov 2010
    Posts
    40
    Yeah, I found that I had set the blend wrong. It was :

    glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);


    instead of this, which seems to work more like what I want:

    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    However, I am still getting my alpha value mangled somehow, if you have time to read my other post just after this one?
    Thanks
    Bob




Posting Permissions

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