Hello everybody,
For a long time I have asked myself questions about this. Take for instance the code below. It will draw a sphere with a certain lighting. This light is directional light and coming from the negative Y-Axis : GLfloat position = {0.0f,-1.0f,0.0f,0.0f};
Yet, and here is the problem: the specular lighting does not seem in order. It is shown as being fixed on a certain spot, and does NOT change when you move the camera around. This is nowhere near what you would expect as reflection.
Can anybody tell me where the problem is located and how to solve this?
void CNewRightView: [img]http://www.opengl.org/discussion_boards/ubb/biggrin.gif[/img]rawSphereWithGlut() { GLfloat ambient[] = {0.6f, 0.6f,0.7f,1.0f}; GLfloat diffuse[] = {0.7f, 0.7f,0.7f,1.0f}; GLfloat position[] = {0.0f,-1.0f,0.0f,0.0f}; GLfloat spec[] = {1.0f, 1.0f,1.0f,1.0f}; GLfloat specma[] = {0.3f, 0.3f,0.3f,1.0f}; glShadeModel(GL_SMOOTH); // Smooth rendering glFrontFace(GL_CCW); // Counter clock-wise polygons face out glEnable(GL_DEPTH_TEST); // Hidden surface removal glEnable(GL_LIGHTING); // Enable lighting glLightfv(GL_LIGHT1,GL_POSITION,position); // Setup and enable light 0 glLightfv(GL_LIGHT1,GL_AMBIENT,ambient); glLightfv(GL_LIGHT1,GL_DIFFUSE,diffuse); glLightfv(GL_LIGHT1,GL_SPECULAR,spec); glEnable(GL_LIGHT1); glEnable(GL_COLOR_MATERIAL); // Set Material properties to follow glColor values glMaterialfv(GL_FRONT,GL_SPECULAR,specma); glMateriali(GL_FRONT,GL_SHININESS,128); glColor3d(0.5,0.5,0.5); glutSolidSphere(0.05,50,50); glDisable(GL_POLYGON_OFFSET_FILL); glDisable(GL_COLOR_MATERIAL); glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); glDisable(GL_LIGHT1); }
[This message has been edited by Simon666 (edited 03-12-2003).]