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 - Clear depth (and color) buffer;
- 2 - Render content A to main framebuffer (with depth test disabled)
- 3 - Render content B to offscreen framebuffer (with depth test enabled)
- 4 - Render content C to main framebuffer (with depth test enabled)
- 5 - Clear depth buffer
- 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:
- - Clearing the depth buffer before rendering content C (step 4);
- - Not clearing the depth buffer in the middle of the frame (step 5 above);
- - Rendering content B to the main framebuffer instead of an offscreen framebuffer (step 3);
- - 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.
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