# why specular light is not running?

this is my method for lighting:

private void lights(GL gl) {
float[] LightPos = {0.0f, 0.0f, -1.0f, 1.0f};
float[] LightAmb = {0.2f, 0.2f, 0.2f, 1.0f};
float[] LightDif = {0.6f, 0.6f, 0.6f, 1.0f};
float[] LightSpc = {0.9f, 0.9f, 0.9f, 1.0f};

gl.glLightfv(GL.GL_LIGHT1, GL.GL_POSITION, LightPos, 0);
gl.glLightfv(GL.GL_LIGHT1, GL.GL_AMBIENT, LightAmb, 0);
gl.glLightfv(GL.GL_LIGHT1, GL.GL_DIFFUSE, LightDif, 0);
gl.glLightfv(GL.GL_LIGHT1, GL.GL_SPECULAR, LightSpc, 0);

gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, LightSpc, 0);

gl.glEnable(GL.GL_LIGHT0);
gl.glEnable(GL.GL_LIGHT1);
gl.glEnable(GL.GL_LIGHTING);
}


and i see my objects flat, no specular light.. any ideas?

ps. to render my objects:

gl.glColor3f(1f,0f,0f);
gl.glBegin(GL.GL_TRIANGLES);
for(Triangle t : tubeModel.getTriangles()) {
gl.glVertex3f(t.v1.x, t.v1.y, t.v1.z);
gl.glVertex3f(t.v2.x, t.v2.y, t.v2.z);
gl.glVertex3f(t.v3.x, t.v3.y, t.v3.z);
}
gl.glEnd();


this is what i'm looking for:

this is what i get:

well it's not all black but if i rotate it becomes grey-white

• how do you set up material? Add it to your post please. – Notabene Jan 8 '11 at 14:40
• sorry i'm not able to log-in with that account and with few post i can't comment. i don't use material.. – nkint Jan 8 '11 at 17:01
• I merged your two accounts you should be able to edit it now – Tetrad Jan 8 '11 at 17:41

You have to set up material.
Enable material:

glEnable(GL_COLOR_MATERIAL);


Set ambient and diffuse to read from what you set in glColor:

glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);


Setup specular. For complete specular you have to have defined specular reflective color and shinines.

float specReflection[] = { 0.8f, 0.8f, 0.8f, 1.0f };
glMaterialfv(GL_FRONT, GL_SPECULAR, specReflection)
glMateriali(GL_FRONT, GL_SHININESS, 56);


Shinines is between 1 - 128. Bigger value = more bright.

You can find more help on these links:
http://www.falloutsoftware.com/tutorials/gl/gl8.htm
http://www.ozone3d.net/tutorials/glsl_lighting_phong.php

• did this answer help? – Notabene Jan 9 '11 at 2:36
• houch. thanks to your answer i understand that is not specular light that does not work but diffuse! – nkint Jan 9 '11 at 11:33
• i added some screenshot to explain better! – nkint Jan 9 '11 at 11:39
• Do you specify normal? – Notabene Jan 9 '11 at 12:04
• Do you have enabled depth buffer and correctly set up gl_cullface? I will post some code to help you, after i return from work (yeah workoholics works at sunday too :)) – Notabene Jan 9 '11 at 13:13

Agree with notabene's answer, material needs to be specified.

But for correct lighting (diffuse and specular) you will also need to specify a normals for each vertex. Although the default normal may create (incorrect) specular reflections.

glNormal3f(x,y,z);

• This is solved in comments under mine answer. But of course you are right ;) – Notabene Jan 12 '11 at 17:51