Sign in to follow this  

OpenGL lighting side-effects

This topic is 4097 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 everybody, OpenGL ligthing give me some matters. I have a scene lighted in a correct way. The scene is traversed by different objects, such as cylinders and spheres; when a cylinder traverses the scene, lighting remain ok, but when I have a sphere, that changes the lighting of other objects in the scene, increasing it, also if for the sphere I'm using a material with all 0s light parameters. Intuitively, the sphere reflects "more" than the cylinder (more faces), but I did not want any kind of this reflection; it seems that I got no such effect setting "diffuse" component at 0.0, but I need diffuse component in my lighting model. What I need is, really, a very simple lighting model (just one light, maybe the Sun) where faces are lighted basing on their orientation, but avoiding them to reflect light over other objects. Is this possible? What I'm mistaking? Thanks in advance! Francesco

Share this post


Link to post
Share on other sites
OpenGL doesn't do any kind of global lighting, so one object moving will not change the other.

However, if the rendering of your objects "leak" state to other objects, then draw order will change what comes out on the screen -- that would be a bug in your code that uses OpenGL (it just does what you tell it to).

If you want a simple solution, use an existing scene graph like Ogre3D or OpenSceneGraph. If you want a complex solution, write your own scene graph (which sounds like what you're trying to do).

Share this post


Link to post
Share on other sites
First make sure you have per-face or per-vertex normals enabled and defined. Then make sure that you are using the correct light model: POINT, DIRECTIONAL, and SPOT should all give you similar lighting models to a degree, but POINT is probably the closest to replicating the sun. AMBIENT light model will light all faces regardless of orientation towards the light. Also make sure you are positioning the light correctly and have the proper light components defined (ambient color, diffuse color).

Share this post


Link to post
Share on other sites

This topic is 4097 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.

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