Diffuse Light Maps

When illuminated by a point light source, matte surfaces display diffuse light reflection. The brightness of diffuse light depends on the distance from the light source and the angle between the surface normal and the light source direction vector.

Your application can simulate diffuse lighting with texture light maps. Do this by adding the diffuse light map to the base texture, as shown in the following code fragment:

// This example assumes that lpD3DDev is a valid pointer to an
// IDirect3DDevice3 interface.
// lptexBaseTexture is a valid pointer to a texture.
// lptexDiffuseLightMap is a valid pointer to a texture that contains 
// RGB diffuse light map data.
 
// Set the base texture.
lpD3DDev->SetTexture(0,lptexBaseTexture );
 
// Set the base texture operation and args
lpD3DDev->SetTextureStageState(0,D3DTSS_COLOROP,
                               D3DTOP_MODULATE );
lpD3DDev->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE );
lpD3DDev->SetTextureStageState(0,D3DTSS_COLORARG2, D3DTA_DIFFUSE );
 
// Set the diffuse light map.
lpD3DDev->SetTexture(1,lptexDiffuseLightMap );
 
// Set the blend stage.
lpD3DDev->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_ADD );
lpD3DDev->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
lpD3DDev->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT );