Strange z buffer artifacts GLES20
#1 Members - Reputation: 121
Posted 08 July 2012 - 05:39 AM
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
#2 Members - Reputation: 4027
Posted 08 July 2012 - 07:48 AM
It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.
#3 Members - Reputation: 121
Posted 08 July 2012 - 04:21 PM
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.
#5 Members - Reputation: 551
Posted 16 July 2012 - 04:59 PM
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.I'm currently not passing any vertex or face normals with my geometry.
#6 Members - Reputation: 121
Posted 19 July 2012 - 09:27 PM
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
#7 Members - Reputation: 121
Posted 19 July 2012 - 10:41 PM
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
#10 Members - Reputation: 121
Posted 19 July 2012 - 10:55 PM
#12 Members - Reputation: 502
Posted 20 July 2012 - 06:29 AM
http://www.opengl.org/sdk/docs/man/xhtml/glCullFace.xmlAnd 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.I'm currently not passing any vertex or face normals with my geometry.
"glFrontFace specifies which of the clockwise and counterclockwise facets are front-facing and back-facing."
Culling is only dependant on winding order. Normals has nothing to do with it.
Culling is done per triangle. How should gpu decide wich is most important normal if every one point in different direction?
#13 Members - Reputation: 551
Posted 20 July 2012 - 09:53 AM
What? That is a lot for anything, let alone a GLES app, plus the fact is on a smaller screen. If it is supported you can use a texture array. Or worst case draw it two times with 8 texture applied at once. You can always disable depth writing for sub-sequent draws. You can use glPolygonOffset with one or both of the values being negative so bring the depth values closer to the viewer, but not the actual geometry. So it will draw the same but with pulled forward depth values so that it will pass the depth test against the previous terrain.I need to apply up to 16 textures per tile
Edited by dpadam450, 20 July 2012 - 10:23 AM.
#14 Members - Reputation: 502
Posted 20 July 2012 - 01:47 PM
I never wind my vertices so it is odd that mine has worked for 6 years. I'm curious to test this now and change the normal to see if it works. I even thought that years ago drawing my first triangle I screwed up the normal and one way it culled and one it didnt. You are correct in that a vertex normal would allow you to slightly see the triangle before its face normal is pointing at you.
This maybe explain winding better.
http://www.arcsynthesis.org/gltut/Positioning/WindingOrder.svg
Vertex data allways have some winding. Either the triangles are in clockwise order or counter clockwise. Its just up to position.
And you can tell the gpu which winding means front face. And yes there is a default value so you don't have choose it if you don't care.
MattFrankling: you can query maximum supported texture units from gpu. This maybe could help you http://www.gamedev.net/topic/548400-glsl-max-number-of-texture-units-per-pass/
#15 Members - Reputation: 121
Posted 07 August 2012 - 05:26 AM
The number of redraws per tile, used for texturing, is the same for my original number of vertices and the version with a quarter of the number of vertices. As such I don't think it is a texturing problem. The size of the textures are the same in both cases.
Since I am using VBO's I doubt it is associated with overall memory allocation as each redraw is simply referring to the same buffer.
I have three theories that I am working with at the moment:
1) With the original number of vertices, the vertices are ending up so close togther that they are rendering to the same pixel more often. This causes an error in the z buffer
2) Some other buffer is being overrun as a result of multiple calls to render the same VBO.
3) I have an error in my VBO's, indexing and texturing that is causing the device driver to fall over somewhere during rendering.
Any thoughts on other possible causes?






