somebody told me that there is a possibility to set something like a tolerance value for the depth test functions i.e. a GL_EQUAL would pass if the difference is within the tolerance. Unfortunately he couldn’t tell me more and I didn’t find the functionality yet. Does anybody know what it could be? Any help appreciated. Thanks in advance.
There’s no such beast in standard OpenGL, and I’m not aware of any vendor-specific extensions for this either.
This would be a significantly more complex depth test though. Instead of just a comparison, you’d need a 24-bit subtraction then a comparison.
For the most part, implementations have gotten pretty good at being depth invariant with a wide variety of state, and for the cases where that’s not applicable, glPolygonOffset works well (as mentioned above).
I believe that PolygonOffset() is what you’re looking for. If you want the tolerance to be X, simply add X for constant polygon offset. This works as long as the comparision function is open or half open – it won’t work for EQUALS.
“tolerance” is such a loose concept though, because you’re “moving the edges out” – but there’s still a finite end where the edge ends; you’re just moving that finite end around, which in the end will probably cause the same problems as you had in the first place. I agree with Cass that the best thing to do is to design for invariance (and that’s also a strict requirement if you need EQUAL for the depth function).