The Mathematics of Direct3D Lighting

Direct3D models illumination by estimating how light behaves in nature. The Direct3D light model keeps track of light color, the direction and distance that light travels, the position of the viewer, and the characteristics of materials to compute two color components for each vertex in a face.

Note  All computations are made in model space by transforming the light's position and direction, along with the camera position to model space using the inverse of the world matrix, then backtransformed. Direct3D uses these color components to compute the color it draws while rasterizing the pixels of a face. As a result, if the world or view matrices introduce non-uniform scaling, the resultant lighting could be inaccurate.

This section presents a technical look at the formulas that Direct3D uses to come up with diffuse and specular components. By understanding Direct3D's approach, you will be better equipped to decide if the Direct3D light model suits your needs. The Direct3D light model was designed to be accurate, efficient, and easy to use. However, if the formulas used by Direct3D don't suit your needs, you can implement your own light model, bypassing the Direct3D lighting module altogether.