Reprinted from: http://blog.csdn.net/ProgramRookie/article/details/4202180
1. Basic illumination model:
Sufacecolor = emissive + ambient + DIFFUSE + specular
The following is the analysis of each item in the formula:
(1) emissive radiation
It is independent of all light sources and is light produced solely by the material of an object. (It is clear in the shader implementation that it cannot be used as a light source to illuminate other objects)
Emissive = ke;
This formula clearly shows that the light color depends entirely on the material.
(2) Ambient ambient light
It is also independent from a single light source. After all, environment two should reflect that this concept is only related to the environment where the object is located, it can be imagined that after multiple refraction of other light, the object is subject to the same intensity of light in all directions.
Ambient = Ka * globalambientlightcolor;
This formula indicates that the color of the vertex depends on its own material and ambient light.
(3) Diffuse diffuse reflection
It is associated with an independent light source. It has nothing to do with the human eye position, and is related to the light position, because of a rough blackboard, the light intensity of a certain point is the same no matter which angle you look at, but if the light source is different, the more inclined the light source is, the less incoming light the point receives.
Diffuse = KD * max (N * l, 0) * lightcolor;
This formula has an additional max (N * l, 0) concept, which indicates that the less the angle between the normal of a point and the angle of the light angle, the stronger the light (the max function is used to indicate that if the light is on the back of the vertex, there should be no light ).
(4) specular mirror reflection
Different from diffuse reflection, the reflected light emitted from the mirror is concentrated in one area. If the eyes leave this area to observe the light points, the less obvious the light is. in addition, objects with better surface gloss have fewer highlights (that is, the more concentrated the reflection ).
Specular = KS * lightcolor * facing * POW (max (N * The center vector between the eye and the incident point, 0), shininess );
it is hard to understand why POW (max (N * The center vector between the eyes and the incident point, 0), shininess) is used) to simulate the effect of the highlight area, I understand that the light that the eyes can observe is the strongest near the reflected light of the incident light based on the vertex normal, that is to say, the smaller the dot product of the center vector and the normal line with vertices and incident light, the larger the intensity of light. as for why the shininess power is used, it is purely to control the size of the highlight area, because the larger the shininess, the faster the light intensity decreases as the angle increases, the larger the highlight area, and the smaller the vice versa.