Jump to content
  • Advertisement
Sign in to follow this  
Richy2k

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

This topic is 4405 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Thats what I was thinking, although the OpenGL superbible is being little help in telling me how to just use positional lighting.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!