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 3 123 LastLast
Results 1 to 10 of 27

Thread: How do you enable a w-buffer?

  1. #1
    Intern Contributor
    Join Date
    Dec 2000
    Location
    Connecticut/New Jersey/Nevada
    Posts
    51

    How do you enable a w-buffer?

    Do you have to use an extension of some sort? In Direct3D it's really simple: m_Device->SetRenderState( D3DRS_ZENABLE, D3DZB_USEW ). I'm sure it's more complicated with OpenGL, but how do you do it? The Red Book does not even allude to the existence of w-buffers.
    ~CGameProgrammer( );

  2. #2
    Advanced Member Frequent Contributor marcus256's Avatar
    Join Date
    Aug 2001
    Location
    Sweden
    Posts
    853

    Re: How do you enable a w-buffer?

    AFAIK OpenGL really only deals with a "depth buffer". It does not specifically say that it's Z or W (only that "very far away" = 1.0, and "very close" = 0.0). I have found no way to controlling the depth buffer format under OpenGL. Perhaps some drivers allow changing this on a global basis (in display settings under Windows, for instance).

  3. #3
    Intern Contributor
    Join Date
    Dec 2000
    Location
    Connecticut/New Jersey/Nevada
    Posts
    51

    Re: How do you enable a w-buffer?

    Well, there's no option for me (with a GeForce2 Go) to select whether OpenGL uses a z-buffer or w-buffer. But I'm sure OpenGL must support this somehow, right?
    ~CGameProgrammer( );

  4. #4
    Senior Member OpenGL Pro cass's Avatar
    Join Date
    Feb 2000
    Location
    Austin, TX, USA
    Posts
    1,058

    Re: How do you enable a w-buffer?

    There is probably an OpenGL extension for w-buffer support, but none that I'm aware of.

    You could implement your own with the depth replace texture shaders on GeForce3 and GeForce4 Ti.

    Thanks -
    Cass
    Cass Everitt -- cass@xyzw.us

  5. #5
    Intern Contributor
    Join Date
    Dec 2000
    Location
    Connecticut/New Jersey/Nevada
    Posts
    51

    Re: How do you enable a w-buffer?

    I have a GeForce2 which doesn't support pixel shaders, but anyway I'd want to support w-buffers on any card that allows it, not just cards that have pixel shading.
    ~CGameProgrammer( );

  6. #6
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Jul 2000
    Location
    S41.16.25 E173.16.21
    Posts
    2,609

    Re: How do you enable a w-buffer?

    >>I have a GeForce2 which doesn't support pixel shaders, but anyway I'd want to support w-buffers on any card that allows it, not just cards that have pixel shading.<<

    i dont believe all cards support it (even with d3d) so it looks like youre stuff with the zbuffer
    which imho is a lot better than a wbuffer.
    if u want more precision at far ranges of the zbuffer theres a few things u can do.
    search this group for examples

  7. #7
    Intern Contributor
    Join Date
    Dec 2000
    Location
    Connecticut/New Jersey/Nevada
    Posts
    51

    Re: How do you enable a w-buffer?

    I wasn't planning on requiring w-buffers, but I should allow it for all cards that support w-buffers without necessarily supporting pixel shading, was my point.

    Anyway I read a tutorial online and discovered that w-buffer are inaccurate at close range, which is definitely Not Good. So I'll just stick with a z-buffer, I guess, and see how good/bad the w-buffer is in D3D.
    ~CGameProgrammer( );

  8. #8
    Advanced Member Frequent Contributor marcus256's Avatar
    Join Date
    Aug 2001
    Location
    Sweden
    Posts
    853

    Re: How do you enable a w-buffer?

    It is my understanding that the precision of the W buffer is equal regardless of distance, while the precision of the Z buffer is better at close distances and worse at far distances. In general, you want the Z buffer behaviour (closer is more important).

    Cass, when I was writing a Glide -> OpenGL wrapper, I was searching high and low for an OpenGL extension that allowed selection of depth buffer format (in Glide you can select W or Z), but I didn't find any.



    [This message has been edited by marcus256 (edited 04-16-2002).]

  9. #9
    Intern Contributor
    Join Date
    Dec 2000
    Location
    Connecticut/New Jersey/Nevada
    Posts
    51

    Re: How do you enable a w-buffer?

    You're right, Marcus; that's what I meant. The W-buffer is more inaccurate at close distances than the z-buffer. The inaccuracy is even throughout, since it's just the floating-point precision that limits it, but close-up it might be very noticeable. For the terrain it won't be noticeable, but for other objects it probably will.
    ~CGameProgrammer( );

  10. #10
    Senior Member OpenGL Pro cass's Avatar
    Join Date
    Feb 2000
    Location
    Austin, TX, USA
    Posts
    1,058

    Re: How do you enable a w-buffer?

    CGameProgrammer,

    Careful. W varies linearly in eye space, so if you stored it in fixed point, the accuracy is independent of the depths being resolved. If you store W in floating point, you *do* change the way precision is distributed. Floating point naturally packs more precision toward zero. That's why some people advocate having a floating point z buffer with a glDepthRange(1,0). The idea would be to try to balance the uneven distribution of the z buffer with the uneven precision distribution of floating point.

    Thanks -
    Cass
    Cass Everitt -- cass@xyzw.us

Posting Permissions

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