PDA

View Full Version : ambient light



nnnnnnn
02-02-2003, 09:44 PM
I'm drawing two cubes with glutSolidCube() which have a light above them.

I want to set the colour of the cube with lighting enabled so I tried to call
glColorMaterial(). It seems that setting diffuse and specular to whatever colour I choose works as intended. I have a white light and set them to red I get a red 'tint'.

If I set emission to green a green colour emits.

However if I set the ambient colour it emits the ambient colour! If I set it to black then I get only the others' contributions, as expected, but if I set it to white I expect it to 'reflect' my current ambient setting, but instead it turns my entire cube white!

I can't find any reason ambient 'casts' light instead of 'reflecting' it.

I'm using a TNT in w2k with the 41.09 drivers.

Mazy
02-03-2003, 12:34 AM
Sure that you understand the light equation?

If im not totally off here it looks something like -
Emission + (Ambient * ambientLight) + (Diffuse * DiffuseLight * DiffuseContribution) + (Specular * SpecularLight * SpecularContribution)

where the light contributions are calculated with blinns light calc.

so a emission does the same as (Ambient * ambientLight) therefore a white ambient and a white ambientlight give you the exact same effect as a white emission.

JustHanging
02-03-2003, 12:41 AM
Hi,

This is a limitation of the opengl's lighting model.

In opengl, ambient means a minimum amount of light that is present everywhere in the scene, it is ment to compensate the lack of global lighting. Other light is added on top of this. Since opengl, incorrectly again, clamps all lighting at (1, 1, 1), white ambient causes all lighting values to get equally white. A gray ambient will propably give the result you want.

-Ilkka

JustHanging
02-03-2003, 12:43 AM
The difference between ambient and emissive light is, that when correctly applied, ambient is modulated with the base texture and emissive is added to it like specular.

vincoof
02-03-2003, 04:25 AM
The difference between ambient and emissive light is, that when correctly applied, ambient is modulated with the base texture and emissive is added to it like specular.
Not sure exactly what ambient you point out, but it's partially true and partially false.
There is an ambient contribution which comes for lights (just as diffuse and specular) and a global ambient illumination that come from "nowhere" (just as emissive).

As for modulating with texture, every light contribution is modulated by texture. The only special case is specular color that can be "separated" using the feature from the GL_separate_specular_color extension (explicit name, isn't it ?) also available in OpenGL1.2. But in no way ambient can be applied after texturing stage in OpenGL.

titan
02-03-2003, 05:52 PM
Originally posted by Mazy:
Sure that you understand the light equation?

If im not totally off here it looks something like -
Emission + (Ambient * ambientLight) + (Diffuse * DiffuseLight * DiffuseContribution) + (Specular * SpecularLight * SpecularContribution)

where the light contributions are calculated with blinns light calc.

so a emission does the same as (Ambient * ambientLight) therefore a white ambient and a white ambientlight give you the exact same effect as a white emission.



So I've got ambient of .2,.2,.2 and [ambient] material colour of .5,.5,.5. Shouldn't the final colour then be .1,.1,.1?

I still don't understand why setting my ambient material colour to .5 causes it's final colour to become .5 (assuming no diffuse or specular) when the scene ambient light isn't 1.0..

vincoof
02-04-2003, 05:38 AM
So I've got ambient of .2,.2,.2 and [ambient] material colour of .5,.5,.5. Shouldn't the final colour then be .1,.1,.1?
If ambient light 0 is (0.2, 0.2, 0.2) and ambient material is (0.5, 0.5, 0.5), then yes the ambient contribution from light0 is (0.1, 0.1, 0.1)

Mazy
02-04-2003, 06:16 AM
Remeber that you have light contribution from both a scene ambient and one ambient pr light.. i assume you have light enabled and are using glMaterial to change material properties

nnnnnnn
02-04-2003, 09:21 PM
Thanks for the help everybody.