View Full Version : Lighting + Texture + Shadow-Color

11-13-2011, 11:22 AM

I have a textured scene. For each vertex I calculated a shadow color which I assign via glColor3f: black: full shadow, white: no shadow. Now I want to add a light-source which darkens faces that are not facing it but does not enlight the shadow.

Adding a simple Light and enabling GL_COLOR_MATERIAL gives me a good starting Point: dark faces stay dark and faces which not face the light source a darkened too. But unfortunatley they are darkened too much.

How can I make them brighter? If I add GL_EMISSION to [.5, .5, .5, 1] they get brighter, but my shadows are also lit up (what I dont want)..

Does someone know a good reference for OpenGL lighting or can give me a Hint how I get the desired effect?

11-13-2011, 03:23 PM
GL_AMBIENT is what you are looking for. It simulates... you guessed it, ambient lighting.
I have used the Red Book as my reference when I was first learning GL. The lighting equation is explained there and probably all other sources.

There is also glLightModel which has a ambient thing. You can set it to {0, 0, 0, 0}.

You also need to set the glLight GL_AMBIENT value. I suggest {1, 1, 1}.