Bad shading result when applying material

opengl

Solution

You forgot to set specular shininess.

`glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 12.0f);`

Set it to 10...25 and it'll look much better/shinier. It won't look as good as per-pixel lighting, though. Default value for shininess is zero which will look exactly like what you see - i.e. ugly.

Problem

I've got an openGL 3d scene with two simple objects (glutSolidCube and glutSolidTeapot). When I set up the lights with GL_COLOR_MATERIAL enabled, I get the following result: Which is good. Then when I set up my own material like this: ``` //diffuse light color variables GLfloat dlr = 0.4; GLfloat dlg = 0.6; GLfloat dlb = 0.9; //ambient light color variables GLfloat alr = 0.7; GLfloat alg = 0.7; GLfloat alb = 0.7; //ambient light color variables GLfloat slr = 0.4; GLfloat slg = 0.4; GLfloat slb = 0.4; GLfloat DiffuseLight[] = {dlr, dlg, dlb}; //set DiffuseLight[] to the specified values GLfloat AmbientLight[] = {alr, alg, alb}; //set AmbientLight[] to the specified values GLfloat SpecularLight[] = {slr, slg, slb}; //set AmbientLight[] to the specified values glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (float *)&AmbientLight); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (float *)&DiffuseLight); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float *)&SpecularLight); ``` I get this very different result, in which you can see it's not being shaded properly, it's like FLAT shading although I defined it as SMOOTH (Gouraud). Where can the problem be? Is it on the material definition?

Original source