Lighting issues - Direction relative to origin? (pics inside)

Started by
3 comments, last by Richy2k 17 years, 9 months ago
Its been just short a year since I last done any graphics programming, so I sit down and start writing a simple engine to write some games with. Got the map loader working, so I've just went to put lighting in, not a difficult task. The only problem is that the lighting is not working correctly. My normals are correct, already checked that, but anyways, here is a few shots: This one is with the light in the same position as the camera. The origin of the world is roughly in the centre of the balls. And now the light position is roughly at the origin. And the light just not being correct inside a quake level - red lines are the vertex normals for each face, and the red ball is the light position. Will be the same problem as is causing my balls to be rendered as if they were using directional lighting. I think that the light is being calculated where the lights direction is relative to the origin, not to each vertex for some reason, but I don't have the foggiest idea why, and no web site or text book is helping me out at all here. Some other information: each one of the those balls is a seperate mesh, the vertices locations are actually where they are draw, the balls dont have a position, just a mesh. After I load my camera matrix into GL, I set the lights position, and then render the mesh of each brush. Anyone had any similar problems with lighting, and if so how did you solve the problem?
Adventures of a Pro & Hobby Games Programmer - http://neilo-gd.blogspot.com/Twitter - http://twitter.com/neilogd
Advertisement
Hey

You're not using directional lighting when you're meant to be using positional are you? That would probably explain the ball pictures I reckon.
Thats what I was thinking, although the OpenGL superbible is being little help in telling me how to just use positional lighting.
Adventures of a Pro & Hobby Games Programmer - http://neilo-gd.blogspot.com/Twitter - http://twitter.com/neilogd
It's when you set the lights position with glLight(), the fourth parameter, after x, y and z determines whether its positional or not.

Set it to 1 for positional, and 0 for directional.
Ah nice one! Thanks! Didn't think that 4th parameter did anything to be perfectly honest. Although I usually set it to 1.0f, I didn't this time for some reason.
Adventures of a Pro & Hobby Games Programmer - http://neilo-gd.blogspot.com/Twitter - http://twitter.com/neilogd

This topic is closed to new replies.

Advertisement