# Thread: OpenGL: How to make surface shiny

1. ## OpenGL: How to make surface shiny

The gluCylinder I drew have a shiny surface that responds to my glMaterialfv() command, but the rectangle i drew myself doesn't shine at all.

How do you draw a surface and make it shiny?

I enable light0, give it some ambient and specular component, and give my surface and cylinder some ambient and specular material properties. the shiny feeling comes up in the cylinder, i did the same for the GL_QUADS i draw but it renders like a dead rectangle with no shiness whatsoever.

Can someone describe to me all the steps to enable the specular property on a surface?

ting

2. Originally Posted by zacs7
Perhaps i should elborate it a little bit. I am not having trouble with making something shiny in general. I am having trouble to make an GL_QUADS surface shiny. It is defined by the following code:

Code:
```  glBegin(GL_QUADS);
glVertex3f(1,-1,1); //top left front
glVertex3f(1,1,1); //top right front
glVertex3f(-1,1,1); //top right back
glVertex3f(-1,-1,1); // top left back
glEnd();```
Before i draw this GL_QUADS rectangle, I put these two lines:
Code:
```  glMaterialfv(GL_FRONT, GL_AMBIENT, green);
glMaterialfv(GL_FRONT, GL_SPECULAR, green);```
thanks for any help.

3. Have you defined the normals for each vertex?

4. ## Solved: glNormal determines the light reflection

Originally Posted by zacs7
Have you defined the normals for each vertex?

I solved it with your help. I put the code:

Code:
`glNormal3f(0,0,1);`
before each vertex and the front side shines exactly the way i wanted. Appriciate it.

ting

6. Somehow I think that hard-coded normal is not going to work in all cases.

To get the normal you subtract two vectors to get two edge vectors. Cross these two vectors and normalize.

Pseudocode:

top_edge = right - left;
left_edge = bottom - left;
normal = normalize(cross(top_edge,left_edge))

For better lighting you would want to determine how many edges shared a common vertex. Average the normals of the current triangle with the normals of the surrounding triangles formed by this common vertex and assign that averaged normal to the current triangle.