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: Drawing to JUST the depth buffer

  1. #1
    Member Regular Contributor
    Join Date
    Sep 2002
    Posts
    384

    Drawing to JUST the depth buffer

    Let's say I am rendering a mirror surface on a flat convex surface. I use the edges of the surface to create clipping planes around the camera, move the camera in a position so that a reflection is rendered, then draw and move the camera back.

    The only problem is that objects still get drawn behind the "mirror". To make the "mirror" occlude objects that lie behind it, I rendered the surface with glBlendFunc set to GL_ZERO,GL_ZERO. This works pretty well, but I still get some graphical glitches, with objects behind the mirror flashing on and off as I move.

    Is there a better way to make OpenGL think I drew an object on that surface, even though I just drew a clipped view from a different camera angle?

    Here is an image of what I am doing. Here, I am actually using the same technique to render the skybox. There is a block of "sky" sitting on the road on the right. You can see the sky through it, and it blocks objects that are behind it. However, when I move around, there are some flashes of other objects on top of the sky surfaces.


  2. #2
    Member Regular Contributor
    Join Date
    Sep 2002
    Posts
    384

    Re: Drawing to JUST the depth buffer

    I fixed it by rendering the sky first, followed by the surface, with a blend mode of zero, one.

    Is there a better way to do this? I would prefer to do away with the big blended surfaces.

  3. #3
    Member Regular Contributor CrazyButcher's Avatar
    Join Date
    Jan 2004
    Location
    Germany
    Posts
    402

    Re: Drawing to JUST the depth buffer

    if you just want depthwrithing turn colormask to false
    glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE)
    you will get a speed boost on most hardware I think, as they are faster on pure zpasses.

  4. #4
    Member Regular Contributor
    Join Date
    Dec 2005
    Posts
    256

    Re: Drawing to JUST the depth buffer

    Hi!

    I got the same problem as you with blending and skyboxes, things don't get drawn well

    ...however I am kind of a newbie...

    Could anyone explain me what does the
    colormask to false
    glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE)
    command do?

    What does it mean to only write to the depth buffer, and how does it fix the initial problem?!

    Thank you so much all in advance!
    Cheers,
    Rod

  5. #5
    Junior Member Regular Contributor
    Join Date
    Sep 2005
    Posts
    105

    Re: Drawing to JUST the depth buffer

    with glColorMask you say to which color channels you want to render. giving all false makes that nothing will be displayed, but it was rendered to depth buffer (if you don't disable that too)

  6. #6
    Junior Member Newbie
    Join Date
    Apr 2004
    Location
    Argentina
    Posts
    28

    Re: Drawing to JUST the depth buffer

    Nice soft shadows

Posting Permissions

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