Just played with things a bit more. I tried reducing the number of vertices in each tile to a quarter of their original number. The problem goes away. Each tile is still being drawn up to 16 times for each associated texture. If I force redrawing each tile twice, including all textures, the problem comes back.
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.
Just seen your responses to my previous post.
How would you propose I use shaders to avoid redrawing the tiles? I need to apply up to 16 textures per tile. I'm fairly sure I can't use that many texture units at once.
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?
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?
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.