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 13

Thread: the precision issue in 16 bit Z-Buffer

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2009
    Location
    beijing
    Posts
    11

    Smile the precision issue in 16 bit Z-Buffer

    Hi ,all:
    I am working at a project that aims to develop a virtual globe system by using WebGL.
    We have made the system work, but there is z-fighting problems.
    I have heard from others that there exists a solution that use a perspective projection matrix,a matrix different from the projection matrix used in the OpenGL,which can resolve/relieve the precision problem.
    Does anyone known the equation of the projection matrix? Thank you very much!

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,201
    An easier option might be to use a higher precision depth buffer. All reasonably civilized hardware will support a minimum of 24-bit, so - have you tried 24-bit and, if so, does the problem go away?

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2009
    Location
    beijing
    Posts
    11
    hi,mhagain,
    chrome does provide 24 bit z-buffer,but some other browsers only support 16 bit z buffer.mhagain,thanks for your reply!

  4. #4
    Junior Member Regular Contributor Kopelrativ's Avatar
    Join Date
    Apr 2011
    Posts
    214
    There is one way to work around this, and that is to use glPolygonOffset. See also http://stackoverflow.com/questions/7...s-in-opengl-es.

    Maybe this is applicable to your problem?

  5. #5
    Member Regular Contributor
    Join Date
    Jan 2005
    Location
    USA
    Posts
    411
    If you need an ultra depth buffer you can slice things into sections from front to back and draw them then from back to front.

    Anything that is in both sides will be drawn twice but clipping should marry the results with any luck. If your globe is not very detailed like an actual planet, then this is probably the wrong way to go. But then 16bit can be killer. Any implementation of WebGL would probably conservatively use the highest precision depth buffer available. On a desktop that will be 24bits for consumer adapters.
    God have mercy on the soul that wanted hard decimal points and pure ctor conversion in GLSL.

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,201
    Quote Originally Posted by kamimail View Post
    hi,mhagain,
    chrome does provide 24 bit z-buffer,but some other browsers only support 16 bit z buffer.mhagain,thanks for your reply!
    This doesn't make much sense. I'll admit that I'm not familiar with particulars of WebGL so I could be horribly wrong, but availability of depth buffer formats should depend on your hardware and driver, not your browser.

  7. #7
    Advanced Member Frequent Contributor
    Join Date
    Apr 2009
    Posts
    595
    Quote Originally Posted by mhagain
    This doesn't make much sense. I'll admit that I'm not familiar with particulars of WebGL so I could be horribly wrong, but availability of depth buffer formats should depend on your hardware and driver, not your browser.
    mhagain is dead on correct. You can open up WebKit and observe that WebGL implementation is more or less (with some variation depending on the backend) just a wrapper (the class is GraphicsContext3D) over GLES2 with some extra junk about making a context current (or something else) when getting ready to draw to it and some extra jazz to get the image data from it to the rest of WebKit so it can draw the 3D canvas.

    Additionally, there is mainstream portable hardware that only has a 16-bit depth buffer: NVIDIA's Tegra2, though they have something funky to help work around the z-fighting issues: http://www.khronos.org/registry/gles..._nonlinear.txt , but AFAIK, unless you have a special build of WebKit (or whatever browser you are using) you are not going to be able to coax the WebGL implementation to take advantage of it.

  8. #8
    Member Regular Contributor
    Join Date
    Dec 2007
    Posts
    253
    use ortho projection instead. With perspective projection all the precision is at the front. The further away from the camera you go the less precision.

  9. #9
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,201
    Quote Originally Posted by dukey View Post
    use ortho projection instead. With perspective projection all the precision is at the front. The further away from the camera you go the less precision.
    Ortho projection isn't much good if you're drawing a scene that you want viewed with perspective though, is it?

  10. #10
    Member Regular Contributor
    Join Date
    Jan 2005
    Location
    USA
    Posts
    411
    Just a thought. To get the most out of the depth buffer the clip space should be restricted to just the bits of the scene that are actually on display.

    So if you need to show a globe. The near clipping plane should be right in front of the globe, and the far clipping plane should be right beyond the horizon.
    God have mercy on the soul that wanted hard decimal points and pure ctor conversion in GLSL.

Posting Permissions

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