Original Post
Hi all, I have a big problem I can't understand. I am rendering a simple cube using this function : glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45, (float)m_iWidth / (float)m_iHeight, 1.0f, 100); glMatrixMode(GL_MODELVIEW); glLoadIdentity (); glTranslatef(0.0f,0.0f,-z); // Translate Into/Out Of The Screen By z glRotatef(xrot,1.0f,0.0f,0.0f); // Rotate On The X Axis By xrot glRotatef(yrot,0.0f,1.0f,0.0f); // Rotate On The Y Axis By yrot glEnable(GL_DEPTH_TEST); glUseProgram(program); drawCube(1, -1); glUseProgram(0); .... I use a shader to change the fragment colors by its depth. The vertex shader is: void main() { gl_FrontColor = gl_Color; gl_Position = ftransform(); } and the fragment shader: void main() { gl_FragColor = vec4(gl_FragCoord.z, gl_FragCoord.z, gl_FragCoord.z, 1); } The problem is when I zoom in direction of the cube I obtain big artifacts (little bands). The normal display (where you an also see the problem even if not easy) is shown here:
Finally, the problem is here:
FYI, this only happens when I rotate the camera. I hope you'll be able to help me. Thank you. [Edited by - nickben on July 16, 2008 7:06:03 AM]
Finally, the problem is here:
FYI, this only happens when I rotate the camera. I hope you'll be able to help me. Thank you. [Edited by - nickben on July 16, 2008 7:06:03 AM]