Forums - Z fighting after rendering to FBO

2 posts / 0 new
Last post
Z fighting after rendering to FBO
COR3 NDrive
Join Date: 1 Oct 10
Posts: 7
Posted: Tue, 2013-09-10 09:48

I'm having a problem that seems like z-fighting, but there are no coplanar triangles.

At every frame I do the following (simplified):

  1. 1 - Clear depth (and color) buffer;
  2. 2 - Render content A to main framebuffer (with depth test disabled)
  3. 3 - Render content B to offscreen framebuffer (with depth test enabled)
  4. 4 - Render content C to main framebuffer (with depth test enabled)
  5. 5 - Clear depth buffer
  6. 6 - Render content D to main framebuffer

 

The problem is that content C displays some z-fighting-like problems (see here and here), but only on a square on the top left corner of the screen (maybe only on one tile?). In fact, everything render with depth test between rendering something to an offscreen buffer and clearing the depth buffer display those problems (but always on the top-left square). It seems that the depth buffer is corrupted after the offscreen FBO.

There are a few workarounds that "fix" the problem, such as:

  1. - Clearing the depth buffer before rendering content C (step 4);
  2. - Not clearing the depth buffer in the middle of the frame (step 5 above);
  3. - Rendering content B to the main framebuffer instead of an offscreen framebuffer (step 3);
  4. - Enabling GL_SCISSOR_TEST.

 

This happens on an HTC Desire S and HTC Desire Z (both Adreno 205) and on an HTC Butterfly (Adreno 320), but not on other devices such as the HTC One SC (Mali 400), the iPhone (PowerVR), etc.

Thank you.

 

  • Up0
  • Down0
mhfeldma Moderator
Join Date: 29 Nov 12
Posts: 310
Posted: Mon, 2013-10-07 07:33

Can you tell what size depth buffer you are using (16 or 24 bit) for both on-screen and off-screen?  Switching to 24 bit might help eliminate the z-fighting.

 

-mark

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.