Skip to main content
gamedev.net
🔒 Locked

OpenGL Lighting problem

Started by Monder 3 replies 650+ views
Original Post
Monder
Monder
In my engine I''ve been using OpenGL lighting, but it doesn''t seem to be working properly. When I set the diffuse colour of the light to 1.0, 1.0, 1.0 and the ambient and specular colours to 0.0, 0.0, 0.0 the model I''m lighting appears evenly lit as if all the light in the scene was ambient, but there is no ambient light in the scene. When I set the diffuse colour of the light to 0.0, 0.0, 0.0, 0.0 everything''s black so it''s definetely the diffuse colour that''s causing it. Does anyone know why this could happen?
Puzzler183
Puzzler183
Where is the light source located? If it is at the camera position, then that seems like normal behavoir to me.
Morten
Morten
Are you passing in any normals? The default normal points in some direction ([0 0 1], I think) and if all your geometry''s using that, it''ll behave as you describe.

-Morten-
Monder
Monder
The normals are there and the light is located at 30.0f, 30.0f, 30.0f in world space. When I set the light position the top of Modelview matrix stack has got the camera matrix in so when OpenGL multiplies the light position by the modelview matrix it''s in eye coordiantes (which is where OpenGL wants the light position to be).

Oh I''ve also written my own lighting implementation that''s meant to replicate the OpenGL one (I posted a thread about it a few days ago), that seems to do the diffuse lighting perfectly correctly. I guess I''m setting an OpenGL parameter wrong, but I''ve got no idea what I''m setting wrong.
Monder
Monder
*Bangs head against table over and over*

You were right Morten, I''m using vertex arrays in my engine, and I was passing normals in, I just forgot to enable GL_NORMAL_ARRAY

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.