Jump to content
  • Advertisement
Sign in to follow this  
ChickenMcOwnage

gl_lighting problem

This topic is 4826 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 working with the basic GL_LIGHTING lights in a first person game. The problem I'm having is that the lights reach forever. I set attenuation (with various combinations) but everything that should be out of reach of the light source (whose origin is the player) can still be seen slightly, no matter how far away. Those areas far enough away should be entirely pitch black. Am I doing something stupid, or are the ogl lights stupid? ...oh by the way, I'm not setting any materials for anything in my program. Thanks! ~Mark

Share this post


Link to post
Share on other sites
Advertisement
A call to glLightModel*() can set your lights to shine an infinite or local distance away. To set your lights to shine a finite distance (locally), call it like this:

glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);

Anywhere in your initialization setup should be fine (definitely not during your rendering loop, unless you want some objects to be lit at infinite distances and others not, but I'm not sure if that would work). The second parameter there is the flag for setting local or infinite lights. True = local (what it sounds like you want), false = infinite. According to the redbook, infinite is the default.

Hope that helps!

Share this post


Link to post
Share on other sites
No, GL_LIGHT_MODEL_LOCAL_VIEWER just sets whether you want to assume an infinite viewpoint or not for specular calculations, it has nothing to do with attenuation or the distance a light shines.

I think what you're probably seeing is the default light model ambient value (which is (0.2, 0.2, 0.2, 1.0)). To change that to zero do something like this...
GLfloat ambient[4] = {0.0f, 0.0f, 0.0f, 1.0f};
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient);
Let us know if that is the problem. If that's not it, post some "relevant" code.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kalidor
No, GL_LIGHT_MODEL_LOCAL_VIEWER just sets whether you want to assume an infinite viewpoint or not for specular calculations, it has nothing to do with attenuation or the distance a light shines.


Just checked the redbook and you're absolutely right. My bad. I'd check the ambient component of your lights, then, as Kalidor said.

Thanks for the correction, Kalidor.

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!