Microsoft DirectX 8.1 (Visual Basic)

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 Microsoft® Visual Basic® code example demonstrates light mapping with RGB color data.

' This example assumes that D3DDevice is a valid reference to a
' Direct3DDevice8 object and that texLightMap is a valid reference
' to a 3DBaseTexture8 object that contains RGB light map data.
 
' Set the light map texture as the first texture.
D3DDevice.SetTexture 0, texLightMap

D3DDevice.SetTextureStageState 0, D3DTSS_COLOROP, D3DTOP_MODULATE
D3DDevice.SetTextureStageState 0, D3DTSS_COLORARG1, D3DTA_TEXTURE
D3DDevice.SetTextureStageState 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE

This sample sets the light map as the first texture. It then sets the 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.