Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - It seems as if glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ...) is interpreted incorrectly: (7 Items)
   
It seems as if glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ...) is interpreted incorrectly  
Default GL_LIGHT_MODEL_AMBIENT equals to {0.2f, 0.2f, 0.2f, 1.0f} and it affects to light equation calculation more than
 it must affect. For example if GL_LIGHT_MODEL_AMBIENT equals to {1.0f, 1.0f, 1.0f, 1.0f} I will get maximum bright 
color without any shadings, but look into the color computation equation when lighting is enabled, you'll see that 
GL_LIGHT_MODEL_AMBIENT must not affect so dramatic to the result color.

The same behavior using software renderer and hardware renderer provided by devg-extreme2.
Re: It seems as if glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ...) is interpreted incorrectly  
The OpenGL 1.3 spec gives the following lighting equation (I assume this is what you were referring to...)

[...]
If c_es = SINGLE COLOR, then the equations to compute c_pri and c_sec are

c_pri = e_cm + a_cm * a_cs + sum(i=0..n-1, att_i * spot_i * [a_cm * a_cli + (n dot VP_pli) * d_cm * d_cli + f_i * exp(n 
dot h_i, s_rm) * s_cm * s_cli])

csec = (0; 0; 0; 0)
[...]

I looked at the software renderer and it does implement the above equation.

What is the value of the ambient color of the material ?
What is the state of the GL_COLOR_MATERIAL cap ?
What is the state of the GL_LIGHT[0..7] caps ?

If GL_COLOR_MATERIAL is enabled,

What is the color material mode for the GL_FRONT, GL_BACK faces ?
What is the state of the GL_COLOR_ARRAY cap ?

If GL_COLOR_ARRAY is disabled, what is the current color (glColor4f) ?
If GL_COLOR_ARRAY is enabled, what are the colors stored in the array ?

Once we know what is the value of a_cm, we can determine if the results of the lighting calculation with 
GL_LIGHT_MODEL_AMBIENT set to (1; 1; 1; 1) is correct or not, assuming no other lights are enabled.
Re: It seems as if glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ...) is interpreted incorrectly  
> The OpenGL 1.3 spec gives the following lighting equation (I assume this is 
> what you were referring to...)
> 
> [...]
> If c_es = SINGLE COLOR, then the equations to compute c_pri and c_sec are
> 
> c_pri = e_cm + a_cm * a_cs + sum(i=0..n-1, att_i * spot_i * [a_cm * a_cli + (n
>  dot VP_pli) * d_cm * d_cli + f_i * exp(n dot h_i, s_rm) * s_cm * s_cli])
> 
> csec = (0; 0; 0; 0)
> [...]
> 
> I looked at the software renderer and it does implement the above equation.

Etienne, at which stage color clamping [-1.0f ... 1.0f] is performed during lighting equation evaluation ? Maybe problem
 is in the distance between vertex and light source calculation, since overbright scene lighting could be appeared only 
if object directly near light source, otherwise light must be attenuated according to vertex distance.
Re: It seems as if glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ...) is interpreted incorrectly  
GL_EMISSION (e_cm in the equation) and GL_LIGHT_MODEL_AMBIENT (a_cs in the equation) are not attenuated based on 
distance (attn_i in the equation).

I did a quick check and color clamping is done at the very last stage to ensure proper evaluation of the color 
derivatives and texture environment during the rasterization process.
Re: It seems as if glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ...) is interpreted incorrectly  
> GL_EMISSION (e_cm in the equation) and GL_LIGHT_MODEL_AMBIENT (a_cs in the 
> equation) are not attenuated based on distance (attn_i in the equation).

> I did a quick check and color clamping is done at the very last stage to 
> ensure proper evaluation of the color derivatives and texture environment 
> during the rasterization process.

Just tested out another parameter {-0.2f, -0.2f, -0.2f, -1.0f} - nagative, based on the default ambient lighting and it 
produces wonderfull gamma of colors instead of darkened one. I think something wrong with negative value of colors in 
the lighting equation.
Re: It seems as if glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ...) is interpreted incorrectly  
I just tested out {-1.0f, -1.0f, -1.0f, -1.0f) as GL_LIGHT_MODEL_AMBIENT and it produces overbrighted color inversed 
scene, but must be very dark colored scene. Definitely lighting equation is evualated incorrectly.
Re: It seems as if glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ...) is interpreted incorrectly  
I'm working now on project, where is my task to convert large OpenGL/Windows engineering visualization project to OpenGL
 ES/QNX.

I can compare now OpenGL/Windows output (using nVidia and ATI chips) and QNX's software and hardware (devg-extreme2) 
OpenGL ES output.

In QNX I get an overbrighten scene in all cases, with the same parameters, many triangles became too bright and when I 
manually trying to make more darken colors, all scene looks like an overbrighten scene painted using dark colors.

P.S. And issue with GL_LIGHT_MODEL_AMBIENT still persist.