Question

I am following the book Pro OpenGL ES for Android and am trying to get the specular to render correctly. Here's what is happening:

strange specular

I am using the OpenTK's ES11.GL.

This is my lighting code:

float[] pos = { -14.0F, 7.0F, -50.0F, 1.0F };

float[] white = { 1.0f, 1.0f, 1.0f, 1.0f };
float[] red = { 1.0f, 0.0f, 0.0f, 1.0f };
float[] green = { 0.0f, 1.0f, 0.0f, 1.0f };
float[] blue = { 0.0f, 0.0f, 1.0f, 1.0f };
float[] grey = { 0.2f, 0.2f, 0.2f, 1.0f };

GL.LightModel(All.LightModelAmbient, grey);

GL.Light(Sunlight, All.Position, pos);
GL.Light(Sunlight, All.Diffuse, white);
GL.Light(Sunlight, All.Specular, red);
GL.Light(Sunlight, All.Ambient, blue);

GL.Material(All.FrontAndBack, All.Specular, red);
GL.Material(All.FrontAndBack, All.Diffuse, green);
//GL.Material(All.FrontAndBack, All.Shininess, 5.0F); -- disabled for testing

GL.ShadeModel(All.Smooth);
GL.Enable(All.Lighting);
GL.Enable(Sunlight);

As I am very new to both 3D and OpenGL, I have no idea what this problem is caused by. If i move the light to the other side, the image is reversed. If the light is from directly in front of the sphere, then no spec is shown at all.

Why would the basic light work correctly, but when including a spec, it fails?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top