Results 1 to 5 of 5

Thread: How to get the depth value on the other side

  1. #1
    Member Contributor
    Join Date
    Jun 2011
    Posts
    90

    How to get the depth value on the other side

    I rendered a model from the viewpoint of the light. The depth buffer contains many 1.0s except the places where my model lies. It is understandable, because the depth of the background is infinite, thus should be 1.

    Now, I want to get the depth value of the points on the other side. I inserted the following statement in my code
    Code :
    glDepthFunc(GL_GREATER);
    This time, the value in the depth buffer are all 1.0.

    My explanation for this is that if OpenGL renders the background first, then the depth buffer will be filled with 1.0, obviously, all the points in the model has a depth value that is less than 1.0, so they cannot pass the depth test.

    Am I right? How to get the depth value on the invisible side?

  2. #2
    Senior Member Regular Contributor imported_tksuoran's Avatar
    Join Date
    Mar 2008
    Location
    Cambridge, UK
    Posts
    223

    Re: How to get the depth value on the other side

    Try glClearDepth(0.0); glDepthFunc(GL_GREATER), clear and render models.

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,135

    Re: How to get the depth value on the other side

    Simple, render the back faces into the depth buffer. Done.

  4. #4
    Member Contributor
    Join Date
    Jun 2011
    Posts
    90

    Re: How to get the depth value on the other side

    Quote Originally Posted by tksuoran
    Try glClearDepth(0.0); glDepthFunc(GL_GREATER), clear and render models.
    This method works fine for me. Thank you very much.

    Quote Originally Posted by thokra
    Simple, render the back faces into the depth buffer. Done.
    Do you mean using
    Code :
    glCullFace(GL_BACK);
    glEnable(GL_CULL_FACE);

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,135

    Re: How to get the depth value on the other side

    No. That's culling the back faces. Rendering the back faces means culling the front faces.

Similar Threads

  1. hang when running two programs side by side
    By remdul in forum OpenGL: Windows
    Replies: 2
    Last Post: 12-29-2011, 09:03 AM
  2. Side-By-Side configuration
    By andersb in forum COLLADA
    Replies: 1
    Last Post: 02-25-2008, 07:34 PM
  3. Replies: 3
    Last Post: 12-16-2004, 08:35 PM
  4. Right side and Left side Lighting not happening
    By iris_raj in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-11-2003, 06:39 PM
  5. wire appears to move from side to side on object
    By JoeFinn in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-18-2001, 09:18 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