PDA

View Full Version : Shininess (or not...)



chennes
07-20-2001, 01:27 PM
Any suggestions as to why the following code does not give me any shininess?




glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
GLfloat white_light[] = { 1, 1, 1, 1.0 };
GLfloat no_light[] = { .1, .1, .1, 1.0 };
glLightfv(GL_LIGHT0, GL_DIFFUSE, no_light);
glLightfv(GL_LIGHT0, GL_SPECULAR, white_light);
glLightfv(GL_LIGHT0, GL_AMBIENT, no_light);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, no_light);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, no_light);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white_light);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 64);

glBegin(GL_TRIANGLES);
//yada, yada, yada


Chris

DFrey
07-20-2001, 01:50 PM
Well, I can think of two possibilities. I notice in the code posted, that you haven't set the position of the light. So maybe the light is not where you expect it to be, or maybe you just left that out of the post.
The other possibility is that your geometry lacks sufficient detail to be lit accurately.

Rob The Bloke
07-20-2001, 03:42 PM
set your shininess value lower. The problem here is that when the shininess param is really high, the are very small margins for the specular highlight to appear. The light would have to be exactly positioned at the camera(more or less) for the highlight to appear.

The other issue is if texturing is enabled also, the highlight will be modulated with the texture colour unless you have seperate specular enabled (geforce & openGL1.2 thing).

You must be aware when using specular highlights that the highlight is dependant on the shininess param, the colour of the highlight, the position of the light & the position of the camera.

chennes
07-21-2001, 07:47 AM
Sorry - I left out a line... the light is at the camera. And the surface is defined quite well (around 20,000 tris). The position of the light is fine, in that everything appears correctly lit from a diffuse source. But no matter what changes I make to the shininess parameters, I get no change in appearance.

Chris

DFrey
07-21-2001, 08:04 AM
That's quite odd, I tested those settings you posted above on a sphere, and it was shiny.

chennes
07-21-2001, 11:15 AM
... that's because I'm stupid. http://www.opengl.org/discussion_boards/ubb/smile.gif

My normals were getting messed up soemwhere along the line... I fixed that, and voila! shininess. Thanks for your help...

Chris