//////////////////////////////////////// //////////////////////////////
The final color value of any vertex on an object (that is, what we can see)
= Result of environment light + Result of scatter reflection on the point light source + Result of mirror reflection on the point light source (also called Phong Model ). !!
There are many points in a triangle. If we use the above formula to calculate each point, the calculation amount is quite large. So, we think,
For a triangle surface, the illumination value of any point (or center point, but the method vector of this point is equal to the Free Method vector) represents the illumination value of the whole surface, which is flat coloring.
The obvious disadvantage of flat coloring is that an object is essentially composed of triangular surface approximation, that is, it looks like it is made of one surface. All, with improved gourand coloring. That is, use interpolation to calculate the illumination value of each point on the surface.
It is mainly from the computer graphics tutorial, a thin book.
//////////////////////////////////////// ////////////////////////////////
Color recognition:
(0, 0) Black, (255,255,255) White, any r = G = B, three equal colors are gray, gray becomes black, clear becomes white.
() Any component value tip is greater than the other two components, and the color of that component is displayed !!!
//////////////////////////////////////// ////////////////////////////////
Color Rendering in d3d:
Metirial is attached to the object surface, and because metirial is composed of ambient, diffuse, specular, and other structs, each struct is a complete RGB color. therefore, the color of the point light source is usually gray (that is, the RGB three-point value is equal, eg (191,191,191) or white (255,255,255 ). it is equivalent to the use of a standard.
Because the color modulation Algorithm in d3d is multiplication (that is, multiplication of each component), and because d3d uses 0.0 ~ 1.0 indicates a color component, instead of 0 ~ 255, color multiplication will not cause overflow.
A example can be worth a thousand words.
Eg:
# Define gray_color 0x00bfbfbf
// Create material
D3dmaterial9 mtrl;
Zeromemory (& mtrl, sizeof (mtrl ));
Mtrl. Ambient. r = 0.75f;
Mtrl. Ambient. G = 0.0f;
Mtrl. Ambient. B = 0.0f;
Mtrl. Ambient. A = 0.0f;
M_pd3ddevice-> setmaterial (& mtrl );
M_pd3ddevice-> setrenderstate (d3drs_ambient, gray_color );
//////
We can see that.
Metirial. Ambient = :( 0.75, 0.0, 0.0) //, that is, the object surface is near Red.
Environment light
Gray_color = ox00bfbfbf = (0.75, 0.75, 0.75), and gray.
Result After calculation:
RST = metirial. Ambient * gray_color = (0.56, 0.0, 0.0) = (144,0, 0 );