Platform SDK: DirectX

Diffuse Reflection Model

[C++]

Direct3D uses the following formula to compute diffuse reflection factors.

In this formula, Rd is the diffuse reflectance factor, D is the direction that the light travels to the vertex, and N is the vertex normal. Vector D is normalized, and vector N is normalized only if the D3DRENDERSTATE_NORMALIZENORMALS render state is enabled. The light's direction vector is reversed by multiplying it by -1 to create the proper association between the direction vector and the vertex normal. This formula produces values that range from -1.0 to 1.0, which are clamped to the range of 0.0 to 1.0 and used to scale the intensity of the light reflecting from the vertex.

After the diffuse reflection formula is applied, the scaled light is then applied to the diffuse reflectance formula to determine the diffuse component at that vertex. The formula that combines ambient and diffuse reflection to create the diffuse component for the vertex looks like this:

In the preceding formula, Dv is the diffuse component being calculated for the vertex, Ia is the ambient light level in the scene, and A is the light intensity for a light source that has been attenuated for distance and spotlight effects (attenuation from Light Attenuation Over Distance multiplied by Spotlight Falloff Model). The L variables represent the light's properties, and the V entries represent the vertex color, where the subscripts a, d, and e applied to each denote the type of color—ambient, diffuse, or emissive. As the formula notation states, the system computes IaVa + Ve once, adding A(RdVdLd + VaLa) for every active light.

If the D3DRENDERSTATE_COLORVERTEX render state is enabled, the system selects colors for V based on the values set for the D3DRENDERSTATE_AMBIENTMATERIALSOURCE and D3DRENDERSTATE_DIFFUSEMATERIALSOURCE render states. Set these render states set to a member of the D3DMATERIALCOLORSOURCE enumerated type to cause the system to use the current material, or a color from the vertex, as the color source.

For more information, see Specular Reflection Model.

[Visual Basic]

Direct3D uses the following formula to compute diffuse reflection factors.

In this formula, Rd is the diffuse reflectance factor, D is the direction that the light travels to the vertex, and N is the vertex normal. Vector D is normalized, and vector N is normalized only if the D3DRENDERSTATE_NORMALIZENORMALS render state is enabled. The light's direction vector is reversed by multiplying it by -1 to create the proper association between the direction vector and the vertex normal. This formula produces values that range from -1.0 to 1.0, which are clamped to the range of 0.0 to 1.0 and used to scale the intensity of the light reflecting from the vertex.

After the diffuse reflection formula is applied, the scaled light is then applied to the diffuse reflectance formula to determine the diffuse component at that vertex. The formula that combines ambient and diffuse reflection to create the diffuse component for the vertex looks like this:

In the preceding formula, Dv is the diffuse component being calculated for the vertex, Ia is the ambient light level in the scene, and A is the light intensity for a light source that has been attenuated for distance and spotlight effects (attenuation from Light Attenuation Over Distance multiplied by Spotlight Falloff Model). The L variables represent the light's properties, and the V entries represent the vertex color, where the subscripts a, d, and e applied to each denote the type of color—ambient, diffuse, or emissive. As the formula notation states, the system computes IaVa + Ve once, adding A(RdVdLd + VaLa) for every active light.

If the D3DRENDERSTATE_COLORVERTEX render state is enabled, the system selects colors for V based on the values set for the D3DRENDERSTATE_AMBIENTMATERIALSOURCE and D3DRENDERSTATE_DIFFUSEMATERIALSOURCE render states. Set these render states set to a member of the CONST_D3DMATERIALCOLORSOURCE enumeration to cause the system to use the current material, or a color from the vertex, as the color source.

For more information, see Specular Reflection Model.