Microsoft DirectX 8.1 (Visual Basic)

Diffuse Lighting

After adjusting the light intensity for any attenuation effects, Microsoft® Direct3D® computes how much of the remaining light reflects from a vertex, given the angle of the vertex normal and the direction of the incident light. Direct3D skips to this step for directional lights because they do not attenuate over distance. The system considers two reflection types, diffuse and specular, and uses a different formula to determine how much light is reflected for each. After calculating the amounts of light reflected, Direct3D applies these new values to the diffuse and specular reflectance properties of the current material. The resulting color values are the diffuse and specular components that the rasterizer uses to produce Gouraud shading and specular highlighting.

Diffuse lighting is described by the following equation.

Diffuse Lighting = sum[Vd*Ld*(N.Ldir)*Atten*Spot] 
The parameters are defined in the following table.
ParameterDefault value TypeDescription
sumN/A N/ASummation of each light's diffuse component.
Vd(0,0,0,0) D3DCOLORVALUEVertex diffuse color.
Ld(0,0,0,0) D3DCOLORVALUELight diffuse color.
NN/A D3DVECTORVertex normal.
Ldir(0,0,0,0) D3DCOLORVALUEDirection vector from object vertex to the light.
Atten(0,0,0,0) D3DCOLORVALUELight attenuation.
Spot(0,0,0,0) D3DVECTORCharacteristics of the spotlight cone.

The value for Vd is one of three values: one of the two possible vertex colors in a vertex declaration, or the material diffuse color. The value is:

Note: If either DIFFUSEMATERIALSOURCE option is used, and the vertex color is not provided, the material diffuse color is used.

To calculate the attenuation (Atten) or the spotlight characteristics (Spot), see Attenuation and Spotlight Terms

Diffuse components are clamped to be from 0 to 255, after all lights are processed and interpolated separately. The resulting diffuse lighting value is a combination of the ambient, diffuse and emissive light values.