Strange z buffer artifacts GLES20

Started by
13 comments, last by MattFranklin 11 years, 8 months ago
I'm looking for ideas as to what might be causing a rendering artifact I'm seeing in my app. My app renders a terrain using tiles with vertical skirts to cover the gaps between tiles. When I render I get parts of the far terrain overdrawing the nearer terrain (see attachment).

I have tried ordering the tiles from nearest to furthest away with no effect.
I have tried ordering the tiles from furthest to nearest with some improvement.

It appears that the depth test is failing on some parts of a triangle but not others. You can see that the top of the hill to the left is being drawn correctly and some of the bottom, but not the middle.
The parts of the scene that get overdrawn seem to change based on the viewing angle. i.e. I can shift by a degree in one direction and suddenly the overdraw dissappears.

I have checked that GL_LEQUAL is being used and depth test enabled.
I've tried using GL_LESS with no improvement
I've checked the blendfunc
I've checked different depthrange values with no real benefits.

Any ideas what the cause might be?

Are there certain overdraw limits or z buffer shortcuts that may be being applied on certain mobiles that I might need to consider? I'm using a Galaxy S.

I'm currently not passing any vertex or face normals with my geometry. Anyone had any experience of that causing issues with depth testing?

Thanks in advance

Matt
Advertisement
What are your near and far clipping planes set to?

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

My first thought was a z buffer fighting problem. so I have played with various near and far clipping planes.
I have tried setting them to near=100 far=5000 and the same artifacts appear.
I have tried setting the near to 1 and far to 1000 with the same results
I have tried setting the near to 1000 and the far to 50000 with the same results.
Even if I zoom in so that the near clip is close to the artifact location they still occur.
The same thing happens randomly with the far clip close to the artifacts.

In practice my near and far planes are recalculated based on how close I am to the terrain.

The problem seems to be mostly caused by the skirts around the terrain which makes me wonder if it is a normal problem as they are at significantly different angle to the screen than the rest of the terrrain.
If I render without skirts the problem is reduced but I still get terrain drawn at near the far clip range overdrawing terrain at the near clip range.
I tried playing with logorithmic z buffer last night. Still seeing the same issue.
It seems like the depth testing is simply being switched off or bypassed in some way. Any ideas would be very welcome.
I'm currently not passing any vertex or face normals with my geometry.[/quote]
And why not? The issue has nothing to do with depth as far as I can guess. It could have to do with normals and would be the first thing I would look at. Try glCullFace() and cull nothing.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

I've tried incorporating normals into my buffer structure. As far as I can tell the normals information is ignored when it comes to front and back face culling. It is only used to calculate lighting. I don't have lighting in my scene so it isn't an issue. An I supposed to set any attributes in the shaders?
I've tried turning Back face culling on and off with no change in the effect. when I turn Front face culling on I only get to see my terrain when I am under it as expected.

Thanks for sticking with me. I'm wondering if it has anything to do with fast z calculations failing for some reason.

Matt
I've done some more digging.
I am drawing the same terrain tile mulitple times and changing the texture between draws to generate layers on the scene. It would appear that drawing geometry multiple times in the same place causes the fault to occur. I'm guessing there may be a limit to the number of writes/overdraws that can be done on a scene before the depth buffer gives up. Any other ideas?

Matt
? Are you using GL_LEQUAL or whatever the parameter for less than or equal to is in glDepthFunc?


And also normals are used for culling. That is the point of culling, surfaces that face away from the viewer.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

Also in 2.0 you have shader support and most likely wont need to draw multiple times.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

It would seem that simply drawing each terrain tile more than once in a scene causes the artifacts to occur. Even if I draw the same tile with the same texture in the same location twice. I've got DepthTest set to GL_LESS so I expect that after the nearest tile is drawn the first time no more writes would occur. It would seem by drawing the tile more than once, despite the depth testing, some sort of error in the depth buffer occurs that allows tiles later in the pipeline to write to the screen. Anyone else seen this issue? Any ideas how I might fix it?

This topic is closed to new replies.

Advertisement