Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Blending with depthbuffer?

  1. #1
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,345

    Blending with depthbuffer?

    I remember back in the old days when I used Glide that you could use the depthbuffer as a blend factor when blending. I never got that much use of it back then but I recently got a thought that it might have been useful for volumetric fogging. Say if you want to do a fog along the floor, you'd only need to draw a quad and blend it with the background using the depth value of the quad minus the depth value in the Zbuffer as a blend factor.
    This way you could do very complex fog volumes too, just draw the outlines of the volume.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    London
    Posts
    503

    Re: Blending with depthbuffer?

    Maybe useful for shadow maps too?

  3. #3
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,345

    Re: Blending with depthbuffer?

    Could perhaps be, not sure how though. How did you think?

  4. #4
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Hannover, Germany
    Posts
    1,074

    Re: Blending with depthbuffer?

    I thought the depth values wouldn't be linear, so they only exist to check wether one is in front of another. Well, if not, that would be definetely cool. But this would mean concurrent reads and writes to the zbuffer multiple times per pixel, wouldn't it? I heard that the bandwidth would already be too small.
    - Michael Steinberg

  5. #5
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,345

    Re: Blending with depthbuffer?

    Well, they could be recalculated to a linear form.
    The depthvalue is going to be read anyway (if you do depthtesting) so using it shouldn't impact performance. However, the way many graphic chips are designed today you'd perhaps need to rearrange the pixel pipeline so you read the depthvalue at an earlier stage, instead of doing the depthtest in the end.

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Sep 2000
    Location
    Santa Clara, CA
    Posts
    1,096

    Re: Blending with depthbuffer?

    Suffice it to say that it would definitely have major pipeline implications.

    - Matt

  7. #7
    Junior Member Regular Contributor
    Join Date
    Apr 2000
    Location
    Redlands, CA, USA
    Posts
    233

    Re: Blending with depthbuffer?

    Originally posted by Humus:
    I remember back in the old days when I used Glide that you could use the depthbuffer as a blend factor when blending.
    Glide does not allow to use depthbuffer as a blend factor.
    But source alpha can be calculated from fragment Z (high 8 bits of it).

    Indeed Glide has some useful stuff (not available in OpenGL).
    It has some support for a detail textures, LOD blending in the texture combiner,..
    It has better support for a multipass rendering with a fog:
    1) It can use pre-fog color (fragment color before fog is applied) as destination blending factor.
    2) Fog mode control allows to apply full fog equation or any of its 2 components (can be emulated with register combiners):
    Cout = (1-f)*Cfr + f*Cfog
    Cout = (1-f)*Cfr
    Cout = f*Cfog

  8. #8
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,345

    Re: Blending with depthbuffer?

    Originally posted by mcraighead:
    Suffice it to say that it would definitely have major pipeline implications.

    - Matt
    You're essentially saying that it would be hard to implement in hardware? I have never fully understood why Z testing must/should be in the end of the pipeline. To me it would make much more sense having it before texturing and stuff. Could you give me any insight on this?

  9. #9
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,345

    Re: Blending with depthbuffer?

    Originally posted by Serge K:
    Glide does not allow to use depthbuffer as a blend factor.
    But source alpha can be calculated from fragment Z (high 8 bits of it).

    Indeed Glide has some useful stuff (not available in OpenGL).
    It has some support for a detail textures, LOD blending in the texture combiner,..
    It has better support for a multipass rendering with a fog:
    1) It can use pre-fog color (fragment color before fog is applied) as destination blending factor.
    2) Fog mode control allows to apply full fog equation or any of its 2 components (can be emulated with register combiners):
    Cout = (1-f)*Cfr + f*Cfog
    Cout = (1-f)*Cfr
    Cout = f*Cfog
    Yes, you're right, I got it wrong.
    I think blending with depthbuffer would be very useful though.

  10. #10
    Senior Member OpenGL Pro
    Join Date
    Sep 2000
    Location
    Santa Clara, CA
    Posts
    1,096

    Re: Blending with depthbuffer?

    I didn't say hard, I just said that it would constrain how the pipeline is set up -- force you into making a certain set of design decisions.

    - Matt

Posting Permissions

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