Jump to content
  • Advertisement
Sign in to follow this  
kordova

OpenGL OpenGL directional lighting problem

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

I am enabling lighting with the following in my initialization:
GLfloat ambient[] = { 0.4, 0.4, 0.4, 1.0 };
GLfloat diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat position[] = { 0.0f, 1.0f, 0.0f, 0.0f };
   
glLightfv( GL_LIGHT0, GL_AMBIENT, ambient );
glLightfv( GL_LIGHT0, GL_DIFFUSE, diffuse );
glLightfv( GL_LIGHT0, GL_POSITION, position );
   
glEnable( GL_LIGHTING );
glEnable( GL_LIGHT0 );

While it looks correct over the terrain in general, the local quads' lighting seem affected by the direction in which I am looking. The more I am angled towards the ground, the darker it becomes (black if looking straight down). Is this normal or am I setting up this lighting incorrectly?

Share this post


Link to post
Share on other sites
Advertisement
I have found out that in order for lights to work properly, their position needs to be set each frame, after you have position your camera (i.e. after gluLookAt() has been called).

Share this post


Link to post
Share on other sites
Quote:
Original post by Eldritch
I have found out that in order for lights to work properly, their position needs to be set each frame, after you have position your camera (i.e. after gluLookAt() has been called).
Hmmm, that is interesting. I shall try it out, thanks.

EDIT: Just right, thanks mate.

[Edited by - kordova on July 22, 2006 2:34:56 PM]

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!