zslevi
10-20-2009, 07:15 AM
I had a previous similar post, now I have a higher quality video demonstarting the problem:
http://www.youtube.com/watch?v=twcc_Gxm53M
So I'm rotating triangles, but there seems to be jumps in lighting. Is it because some kind of Z fighting? ( I tried with single triangles and with duplicated triangles, but opposite normals.) Do I have to rotate the lights in the opposite direction relative to the camera? Do I have to rotate lights at all?
The current code:
void update(int v){
if (play){
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); //Reset the camera
gluLookAt
(sin(angle)*3,cos(angle)*3,0.4,
0.0,0.0,0.0,
0.0,0.0,1.0);
GLfloat lightPos0[] = {-1.0*sin(angle+80.0), cos(angle+80.0), 0.1f, 1.0f};
glLightfv(GL_LIGHT0, GL_POSITION, lightPos0);
glCullFace(GL_BACK);
angle = angle + 0.03;
glutPostRedisplay();
}
glutTimerFunc(50, update, 0);
}
http://www.youtube.com/watch?v=twcc_Gxm53M
So I'm rotating triangles, but there seems to be jumps in lighting. Is it because some kind of Z fighting? ( I tried with single triangles and with duplicated triangles, but opposite normals.) Do I have to rotate the lights in the opposite direction relative to the camera? Do I have to rotate lights at all?
The current code:
void update(int v){
if (play){
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); //Reset the camera
gluLookAt
(sin(angle)*3,cos(angle)*3,0.4,
0.0,0.0,0.0,
0.0,0.0,1.0);
GLfloat lightPos0[] = {-1.0*sin(angle+80.0), cos(angle+80.0), 0.1f, 1.0f};
glLightfv(GL_LIGHT0, GL_POSITION, lightPos0);
glCullFace(GL_BACK);
angle = angle + 0.03;
glutPostRedisplay();
}
glutTimerFunc(50, update, 0);
}