I am working on an OpenGL project, and I want at least a little coverage in it. I have been trying to use OpenGLs built into lighting for a while, but I have not had much success.
The models I load have their correct normals (calculated by Wings3D) attached to the vertices in this order:
loop all faces {
GL.Normal3(...);
GL.TexCoord2(...);
GL.Vertex3(...);
... (two more in same order, faces are all triangles)
}
Models have several challenges Materialup to GL.Begin(BeginMode.Triangles)how:
GL.Material(MaterialFace.FrontAndBack, MaterialParameter.AmbientAndDiffuse, new float[] { 1.0f, 1.0f, 1.0f, 1.0f });
GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Specular, new float[] { 1.0f, 1.0f, 1.0f, 1.0f });
GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Shininess, 99.0f);
Here are the first three normals of the first loaded model (validation) n (x, y, z):
0(0.6331236, 0.428246439, 0.6447942)
1(0.507037938, -0.6987222, 0.504677951)
2(-0.768829644, -0.494915247, 0.404919624)
Here's how I set up the lighting:
GL.Enable(EnableCap.DepthTest);
GL.Enable(EnableCap.Blend);
GL.Enable(EnableCap.ColorMaterial);
GL.Enable(EnableCap.Texture2D);
GL.Enable(EnableCap.Normalize);
GL.ShadeModel(ShadingModel.Flat);
GL.Enable(EnableCap.Lighting);
GL.Enable(EnableCap.Light0);
GL.Light(LightName.Light0, LightParameter.Position, new float[] { 0.0f, 1000.0f, 0.0f, 1.0f });
GL.Light(LightName.Light0, LightParameter.Ambient, new float[] { 1.0f, 1.0f, 1.0f, 1.0f });
GL.Light(LightName.Light0, LightParameter.Specular, new float[] { 0.0f, 0.0f, 0.0f, 0.0f });
GL.Light(LightName.Light0, LightParameter.Diffuse, new float[] { 1.0f, 1.0f, 1.0f, 1.0f });
GL.Light(LightName.Light0, LightParameter.SpotExponent, 0.0f);
Objects respond to parameters that are reproduced, but all faces sadly have the same brightness.
Am I missing something or am I doing something wrong?