Results 1 to 7 of 7

Thread: fog and alpha

  1. #1
    Senior Member Regular Contributor
    Join Date
    Nov 2004
    Location
    San Diego, CA, USA
    Posts
    122

    fog and alpha

    Fog seems to have an odd effect on translucent objects: The fog color affects them much more than opaque objects at the same distance from the viewer, and even if the alpha is 0.99, applying fog makes the translucent object much more translucent. Any idea what I could be doing wrong?

  2. #2
    Senior Member Regular Contributor
    Join Date
    Sep 2001
    Location
    Eastern USA
    Posts
    218

    Re: fog and alpha

    Remember when you're blending that you are including the existing fragment in the result, thus if you overlap translucent objects you can effectively double your fog coverage.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Nov 2004
    Location
    San Diego, CA, USA
    Posts
    122

    Re: fog and alpha

    Originally posted by Omaha:
    Remember when you're blending that you are including the existing fragment in the result, thus if you overlap translucent objects you can effectively double your fog coverage.
    I don't get that. Say I'm using white fog, and I render a triangle far enough away to be turned completely white. Then I overlap that with a triangle that's a little closer, so it doesn't turn completely white, and with an alpha of 0.99. The fact that there was something behind should make little difference. White fog shouldn't be able to make anything more white that a white clear color.

    Perhaps pictures can make it clearer what I'm talking about. Here's a slightly transparent torus with white fog on its far side...


    That's not so weird. But here is what it looks like when it is approximately edge-on:

    Why is the distant white shining through the near blue?

  4. #4
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: fog and alpha

    It looks like a lack of depth sorting/zbuffer.

  5. #5
    Guest

    Re: fog and alpha

    ...FYI, fog blending has no affect on the rasterized alpha (spec, page 192)...

  6. #6
    Senior Member Regular Contributor
    Join Date
    Nov 2004
    Location
    San Diego, CA, USA
    Posts
    122

    Re: fog and alpha

    Originally posted by ZbuffeR:
    It looks like a lack of depth sorting/zbuffer.
    Yet I am sorting the triangles back to front. If I turn off the fog and reduce the alpha, everything looks right.

  7. #7
    Senior Member Regular Contributor
    Join Date
    Nov 2004
    Location
    San Diego, CA, USA
    Posts
    122

    Re: fog and alpha

    Oops, never mind, found my bug. I was using another pass to draw specular highlights on transparent stuff, and neglected to turn off fog then. With fog off in the specular pass, things look more reasonable, at least with white fog.

Similar Threads

  1. Replies: 1
    Last Post: 08-03-2012, 12:13 AM
  2. Replies: 3
    Last Post: 06-16-2011, 12:51 PM
  3. alpha blending without modifying destination alpha
    By GordAllott in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 09-21-2009, 04:15 AM
  4. Source Alpha Blending without an Alpha Buffer
    By niallm in forum OpenGL ES
    Replies: 1
    Last Post: 06-18-2009, 02:51 AM
  5. Alpha to coverage vs alpha test
    By imported_Groovounet in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 01-21-2008, 12:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean