I've got a Problem with my specular highlights. My situation:
An object (like an egg), my camera(which I set with gluLookAt(...) and a positional light ( light-egg-camera angle is 45 degrees in xz-plane). I turn the camera around the egg (the light alway this 45 degrees next to the camera). The problem is, that the highlights are computed someway wrong. It appears not always on the lighten side of the egg. Sometimes it appears on the dark side. Here some code:
m_Ambient[0] = 0.0f;
m_Ambient[1] = 0.0f;
m_Ambient[2] = 0.1f;
m_Ambient[3] = 1.0f;
m_Diffuse[0] = 1.0f;
m_Diffuse[1] = 1.0f;
m_Diffuse[2] = 1.0f;
m_Diffuse[3] = 1.0f;
m_Specular[0] = 1.0f;
m_Specular[1] = 1.0f;
m_Specular[2] = 1.0f;
m_Specular[3] = 1.0f;
m_Shinyness = 100.0f;
for the material of the egg.
plus in the egg-render-function
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, m_Ambient);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, m_Diffuse);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, m_Specular);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, m_Shinyness);
for the light:
m_Diffuse[0] = 1.0f;
m_Diffuse[1] = 1.0f;
m_Diffuse[2] = 1.0f;
m_Diffuse[3] = 1.0f;
m_Specular[0] = 1.0f;
m_Specular[1] = 1.0f;
m_Specular[2] = 1.0f;
m_Specular[3] = 1.0f;
plus
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
glLightfv(GL_LIGHT0+m_lnumber, GL_POSITION, m_params);
glLightfv(GL_LIGHT0+m_lnumber, GL_DIFFUSE, m_Diffuse);
glLightfv(GL_LIGHT0+m_lnumber, GL_SPECULAR, m_Specular);
glEnable(GL_LIGHT0+m_lnumber);
Does anybody have an idea...?