Microsoft DirectX 8.1 (Visual Basic) |
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]
Parameter | Default value | Type | Description |
---|---|---|---|
sum | N/A | N/A | Summation of each light's diffuse component. | Vd | (0,0,0,0) | D3DCOLORVALUE | Vertex diffuse color. |
Ld | (0,0,0,0) | D3DCOLORVALUE | Light diffuse color. |
N | N/A | D3DVECTOR | Vertex normal. |
Ldir | (0,0,0,0) | D3DCOLORVALUE | Direction vector from object vertex to the light. |
Atten | (0,0,0,0) | D3DCOLORVALUE | Light attenuation. |
Spot | (0,0,0,0) | D3DVECTOR | Characteristics 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.