Sign in to follow this  
kordova

OpenGL OpenGL directional lighting problem

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this