Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

BradDaBug

Its so beautiful on the underside!

This topic is 5681 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''ve been making a lanscape engine using OpenGL Game Programming and lots of code from it. I tried to add some lighting to it, so I created some normals and a light. But when the land is rendered, the lighting is all wrong. Its like there is no lighting when you look at it straight on, and if you turn wierd angles then it''ll get darker and stuff. But, if you go beneath the land and look up at it from the bottom, it looks perfect! I mean, PERFECT! I tried multiplying the normal vector by -1 to see if the normal just needed inverting, but that seems to completely destroy the normal and its rendered like there are no normals. What could be wrong?

Share this post


Link to post
Share on other sites
Advertisement
Quoth the poster: "if you turn wierd angles then it''ll get darker and stuff"

Sounds like you''re not putting your light position through your viewing transformations. That is, if you''re using gluLookAt( ... ) (for example), you''re not resetting the light position so that it goes through the same transforms as the rest of the world - it stays static relative to the ''camera''.

Share this post


Link to post
Share on other sites
You can''t just set the light position once during initialization? You have to re-set it each time you move the camera?

I''m doing something like this:

InitOpenGL()
{
...
glLightfv(GL_LIGHT0, GL_POSITION, position);
...
}

Render()
{
...
}

But, just to make sure I get what you''re saying, I''m supposed to do this:

InitOpenGL()
{
...
}

Render()
{
glLightfv(GL_LIGHT0, GL_POSITION, position);
}

Is that right?

Share this post


Link to post
Share on other sites

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