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

Thread: I'm in a bind :) Viewspace/DepthBuffer

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2000
    Posts
    27

    I'm in a bind :) Viewspace/DepthBuffer

    I can't figure out how to do something..

    I want to render a skydome and when I do that, all of the triangles will be far away.. ( z values around - 10000 ) or so..

    Here is my problem
    My View matrix is built like this..
    gluPerspective(45.0f,(GLfloat)srn.d[0]/(GLfloat)srn.d[1],1.0f,1000.0f);

    Notice the 1.0f , 1000.0f

    Now when i goto render my triangles... I turn off depth test and depth buffer writes...

    I want to render my triangles but they will all bout of of the 1.0f - 1000.0f range from my view matrix...

    How can I get around this????

    I don't want to raise my viewmatrix to 10000.0f because then you get lots of jaggies with other polys that are close up.

    Does anyone know what I'm talking about???

    Please help me out with this bind..!

    Thankx,
    Mongoose

  2. #2
    Junior Member Newbie
    Join Date
    Jun 2000
    Posts
    27

    Re: I'm in a bind :) Viewspace/DepthBuffer

    O yeah and one more thing..

    What is the command to turn on/off depth buffer writes??

    I know you have to do this
    glEnable or glDisable( GL_DEPTH_TEST ) to turn off the testing...

    But I want to turn off both the test and the writes..

    Thankx,
    Mongoose

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jun 2000
    Location
    Shreveport, LA, USA
    Posts
    1,505

    Re: I'm in a bind :) Viewspace/DepthBuffer

    I don't fully understand what your first question is about, sorry. But for your second question, disable depth writes with glDepthMask(GL_FALSE);

  4. #4
    Junior Member Newbie
    Join Date
    Jun 2000
    Posts
    27

    Re: I'm in a bind :) Viewspace/DepthBuffer

    Originally posted by DFrey:
    I don't fully understand what your first question is about, sorry. But for your second question, disable depth writes with glDepthMask(GL_FALSE);
    To make you understand the problem just set up your perspective matrix as I do and render a few triangles off in the z distance by about 5000...

    I'm trying to figure out a way to turn the distance check off!

  5. #5
    Junior Member Regular Contributor
    Join Date
    Aug 2000
    Location
    USA
    Posts
    100

    Re: I'm in a bind :) Viewspace/DepthBuffer

    It sounds like you are experiencing problems with depth-buffer precision. A couple of options that come to mind are:
    - minimize the distance between the near & far clip planes, either by bringing the far clip plane closer to your viewpoint or moving the near clip plane out a bit
    - use a higher-prcision depth buffer (eg, 32-bit)

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

    Re: I'm in a bind :) Viewspace/DepthBuffer

    Originally posted by Mongoose:
    I'm trying to figure out a way to turn the distance check off!
    That can't be done (the distance check, by the way, is clipping).

    Instead, disable GL_DEPTH_TEST and draw the skybox/skydome safely within your near/far clip planes. For example, if you have near and far of 1 and 1000, drawing a sphere of radius 30 is definitely safe.

    The depth information is still used for other things, such as fog and perspective correction, but for perspective correction, only the ratios of W values matter, not their absolute values.

    Note that disabling GL_DEPTH_TEST automatically turns off depth writes. If you want to write to depth but not test it, you need to enable GL_DEPTH_TEST and set the DepthFunc to GL_ALWAYS, with the DepthMask set to GL_TRUE.

    - 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
  •