Jump to content
  • Advertisement
Sign in to follow this  
Sumo

lighting being transformed along with models?

This topic is 4498 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

Hi, I have a game in progress and I have a problem with the lighting. This might be a simple problem to solve but bare with me please. I have a house rendered and a character in front of it. Lighting is fine but when I walk round the side of the house the light seems to move with the camera. To explain better, for example, if my house's side facing the camera at startup was in shadow, the face facing away from the camera would be in full brightness right? But when I move around the other side of the house it ends up that it is in shadow, in fact anything that is facing the camera ends up in shadow. this would not be a problem if I intended the game to be a model viewer and I was just spinning the house around but its not. I think it's down to how I have rotated and translated the model for the house. My render function goes something along the lines of: gluLookAt() pushMatrix() glTranslate() draw sky box popMatrix() pushMatrix() glTranslate() glRotate() render house popMatrix() pushMatrix() glTranslate() glRotate() render character popMatrix() // end rendering Am I doing these things in the right order? I was always taught to translate the world to move the character. Am I doing it wrong for games becasue it works for model viewers. Thanks for any help!

Share this post


Link to post
Share on other sites
Advertisement
I think the easiest way for you to do that would be to have the call to set up the lighting within:

pushMatrix()
glTranslate()
glRotate()
render house
popMatrix()

So that the lights are positioned in accordance with the world (in this case the house).

I believe

hope it helps

Share this post


Link to post
Share on other sites
so would I call glLight(GL_POSITION, pos) just before I render the house like so?

pushMatrix()
translate()
rotate()
glLight()
render house
popMatrix()

Share this post


Link to post
Share on other sites
I think you're either doing things in the wrong order, or you're putting the viewpoint transformation into the projection matrix.

The projection matrix SHOULD be set up so that the camera appears at the origin. Then, set the camera position by translating the MODELVIEW matrix.

It's an easy mistake to make, and it feels right, but it isn't. :)

Mark

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!