Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Depth buffer rendered over objects

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2013

    Depth buffer rendered over objects


    I'm having a bit of a problem with the depth buffer. When I'm using blending, it seems that the depth buffer gets mixed together with the blended image. As soon as I call glDisable(GL_DEPTH_TEST), the entire contents of the depth buffer get written over the render target. If I keep the depth buffer on but disable blending, everything is fine. Here's what I mean:

    Here's the render code:
    Code :
    // render the particles
    glDrawArraysInstanced(GL_TRIANGLES, 0, model_.getVertCount(), NUM_OF_PARTICLES);

    No clue as to what's going on. Any help would be appreciated!

    Thanks in advance!

    EDIT: Just before I went to bed I got an idea and it worked: enabling back face culling removed the issue. I was trying to find a way to delete the topic as to not clutter the forums but I couldn't find a button for it. Anyway, if anyone experiences similar artifacts then here's your solution! ^^
    Last edited by dr4cula; 08-28-2013 at 03:38 PM.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    The problem you were seeing is caused by your blending function being order dependent (i.e. you only get the correct blending result if you render from back to front). Perhaps you are already sorting your spheres by distance from the camera (if not you should, otherwise the issue will come back), but that will not ensure that the triangles that make up each sphere are also rendered from back to front. Enabling back face culling solves the problem because then the problematic triangles are simply dropped - for more complicated (esp. non-convex) geometry backface culling is not enough to get a correct result (although possible a good-enough one ).

Posting Permissions

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