### Phong Lighting

 DIFFUSE LIGHTING:When light strikes a point in a rough surface, the light rays scatter in various random direction; this is called a diffuse reflection. In our approximation for modeling this kind of light/surface interaction,,, we stipulate that the light scatters equally in all directions above the surface; consequently, the reflected light will reach the eye no matter the viewpoint (eye position). Therefore, we do not need to take the viewpoint into consideration, and the color of a point on the surface will always look the same no matter the viewpoint.We break the calculation of diffuse lighting into two parts. For the first part, we specify a diffuse light color. The diffuse material specifies the amount of incoming diffuse light that the surface reflects and absorbs; this is handled with a componentwise color multiplication. For example, suppose some point on a surface reflects 50% incoming red light, 100% green light, and 75% blue light, and the incoming  light color is 80% intensity white light. Hence the incoming diffuse light color is given by cD = (0.8, 0.8, 0.8) and the diffuse material color is given by mD == (0.5, 1.0, 0.75); then the amount of light reflected off the point is given by:cD x mD = (0.8, 0.8, 0.8) x (0.5, 1.0, 0.75) = (0.4, 0.8, 0.6)To finish the diffuse lighting calculation, we simply include Lambert's cosine law. AMBIENT LIGHTING:Our lighting model does not take into consideration indirect light that has bounced off other objects in the scenes. However, much of the light we see in the real world is indirect. To sort of hack this indirect light, we introduce  an ambient term to the lighting equation:cA x mAThe color cA specifies the total amount of indirect (ambient) light a surface receives from a light source. The ambient material color mA specifies the amount of incoming ambient light that the surface reflects and absorbs. All ambient light does is uniformly brighten up the object a bit - there is no real physics calculation at all. The idea is that the indirect light has scattered and bounced  around the scene so many times that it  strikes the object equally in every direction.SPECULAR LIGHTING:When light strikes a  smooth surface, the light rays reflect sharply in a general direction through a cone of reflectance; this is called a specular reflection. In contrast to diffuse light, specular light might not travel into the eye because it reflects in a specific direction; the specular lighting calculation is viewpoint dependent.. This means that as the position of the eye changes within the scene, the amount of specular light it receives will change.PARALLEL LIGHT:A parallel light or directional light approximates a light source that is very far away. Consequently, we can approximate all incoming light rays from this light as parallel to each other. A parallel light source is defined by a vector, which specifies the direction the light rays travel. Because the light rays are parallel, they all use the same direction vector. The light vector aims in the opposite direction the light rays travel.     POINT LIGHT:A good physical example of a point light is a light bulb; it radiates spherically in all directions. In particular, for an arbitrary point P, there exists a light ray originating from the point light position Q traveling toward the point. As usual, we define the light vector to go in the opposite direction; that is, the direction from point P too the point light source Q:L = (Q - P) / || Q - P ||Essentially, the only difference between point lights and parallel lights is how the light vector is computed - it varies from point to point for point lights, but remains constant for parallel lights.For point lights we include an additional range parameter. A point whose distance from the light source is greater than the range does not receive any light from that light source. This parameter is useful for localizing a light to a particular area. The range parameter is also useful for shader optimization. If the point is out of range,  then we can return early and skip the lighting calculations with dynamic branching.SPOT LIGHT:A good physical example of a spotlight is a flashlight. Essentially, a spotlight has a position Q, is aimed in a direction d, and radiates light through a cone. To implement a spotlight, we begin as we do with a point light. The light vector is given by:L = (Q - P) / ||  Q - P ||where P is the  position of the point being lit and Q is the position of the point being lit and Q is the position of the spotlight.Also the light at the center of the cone should be the most intense and the light intensity should fade to 0 as the inner angle increases from 0 to MaxAngle.BIBLIOGRAPHY:Introduction to 3D Game Programming with DirectX10, Frank Luna, 2008VIDEO DEMOSTRATION:SOURCE CODE:http://code.google.com/p/dx10/