Color Light Maps

Your application will usually render 3-D scenes more realistically if it uses colored light maps. A colored light map uses the RGB data in the light map for its lighting information. The following code fragment demonstrates light mapping with RGB color data:

// This example assumes that lpD3DDev is a valid pointer to an
// IDirect3DDevice3 interface and that lptexLightMap is a valid
// pointer to a texture that contains RGB light map data.
 
// Set the light map texture as the 1st texture.
lpD3DDev->SetTexture(0, lptexLightMap);
 
lpD3DDev->SetTextureStageState(0,D3DTSS_COLOROP,  
                               D3DTOP_MODULATE);
 
lpD3DDev->SetTextureStageState(0,D3DTSS_COLORARG1,  
                               D3DTA_TEXTURE);
 
lpD3DDev->SetTextureStageState(0,D3DTSS_COLORARG2,
                               D3DTA_DIFFUSE);
 

This sample sets the light map as the first texture. It then sets state of the first blending stage to modulate the incoming texture data. It uses the first texture and the current color of the primitive as the arguments to the modulate operation.