Taliadon
Taliadon

Reputation: 438

OpenGL ambient light

Having constructed a very simple OpenGL program consisting of a centered textured cube with respective vertex/normal values of +/-1.0, I have two questions regarding the behaviour of the fixed-pipe lighting model.

1) Why is my object not fully illuminated when I set the global ambient light to {1.0, 1.0, 1.0, 1.0}. I would have expected these settings to render the model as if lighting had been disabled (i.e. all surfaces are rendered at full intensity).

2) When I place a diffuse light directly in front of the model at {0.0, 0.0, 2.0} everything appears to render correctly, but if I move the light further back at {0.0, 0.0, 200.0} the model renders as if lighting has been disabled (i.e. all surfaces are rendered at full intensity).

Upvotes: 1

Views: 1763

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 473192

Since you didn't post your actual setup code, all I can really do is guess.

1: The ambient light intensity is modulated with the ambient surface color. If you have not set up your material correctly, then this value will not be the same as the diffuse surface color. Of course, since you didn't post the code, I can't say if you did it correctly or not.

2: I'd need to see a rendering of what's happening, but this is likely caused by not having any kind of intensity falloff. Effectively, as the light gets farther away, it appears brighter, because the normals are more likely to be closer to facing it than if it is close to the surface. A point light becomes a directional light when it is moved away. So you need to use attenuation.

Upvotes: 3

Related Questions