Sunday 12 May 2013

OpenGL ES 1.1 how to choose proper value for ambient/diffuse/specular color for light and material

Usually the color of a lighted object is summation of three parts: ambient, diffuse and specular.

The ambient part is the ambient light color times the object ambient material color. It does not depend on light position nor eye position.

The diffuse part is the diffuse light color times the object diffuse material color times a factor. It depends on light position but not eye position.

The specular part is the specular light color times the object specular material color times a factor. It depends on both light position and eye position.

There could be an emission part, which is similar to ambient part but does not need a light.

To view the contribution of the three parts to the final object color, you can enable just one type of light or material and disable other types of light or material and see the rendered object.

Since the three parts are summed together, you cannot let them all have strength 1, otherwise the color of the object becomes too bright like a photo with over exposure. You need to give each part a weight so that their summation does not exceed 1 in most positions.

The diffuse part provides most of the visual cue to the shape of the object. Therefore I usually give it a weight of 0.7, that is, diffuse light illuminance times diffuse material illuminance is around 0.7.

 You may want some ambient color if you do not want to have dark part of the object. However, too much ambient part gives your object a washed out feeling, so you do not want too much of it. A weight of 0.3 seems to be a good choice.

The specular part gives a shiny spot on your object. Usually a weight of 0.1 is good choice.  There is another parameter called shininess to control how much this shiny spot spreads out. A value of about 100 gives you a small bright spot whereas a value of 10 gives you less bright shiny patches.



No comments:

Post a Comment