When I optimized my models to triangles strips, I came across an annoying z-fighting problem when drawing the shadow volume front cap. This only occurs when I draw the model with triangle strips (I draw the shadow volume front cap using a triangle list, GL_TRIANGLES). I’ll illustrate the problem with a few lines of code:
// vertices
vec3 v0(-100, 0, -100);
vec3 v1(-100, 0, 100);
vec3 v2( 100, 0, 100);
vec3 v3( 100, 0, -100);
// first pass
glColor3ub(255,0,0); // Red
glBegin(GL_TRIANGLE_STRIP);
glVertex(v0);
glVertex(v1);
glVertex(v3);
glVertex(v2);
glEnd();
// second pass, no depth write
glDepthMask(0);
glDepthFunc(GL_EQUAL);
glColor3ub(255,255,0); // Yellow
glBegin(GL_TRIANGLES);
glVertex(v0);
glVertex(v1);
glVertex(v2);
glVertex(v0);
glVertex(v2);
glVertex(v3);
glEnd();
glDepthMask(1);
glDepthFunc(GL_LESS);
Result, http://sunray.cplusplus.se/dump/zfight.png
I’m using a Radeon 9700 Pro with Catalyst 3.8 Beta.
My question is; is this an expected behaviour?
– Sunray