🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

OpenGL lighting side-effects

Started by
1 comment, last by swordfish 17 years, 9 months ago
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
Advertisement
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).
enum Bool { True, False, FileNotFound };
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).
http://blog.protonovus.com/

This topic is closed to new replies.

Advertisement