Microsoft DirectX 8.1 (Visual Basic) |
Some older 3-D accelerator boards do not support texture blending using the alpha value of the destination pixel. See Alpha Texture Blending for more information. These adapters also generally do not support multiple texture blending. If your application is running on an adapter such as this, it can use multipass texture blending to perform monochrome light mapping.
To perform monochrome light mapping, an application stores the lighting information in the alpha data of its light map textures. The application uses the texture filtering capabilities of Microsoft® Direct3D® to perform a mapping from each pixel in the primitive's image to a corresponding texel in the light map. It sets the source blending factor to the alpha value of the corresponding texel.
The following C++ code example illustrates how an application can use a texture as a monochrome light map.
' This example assumes that D3DDevice is a valid reference to a ' Direct3DDevice8 object and that texLightMap is a valid reference ' to a Direct3DTexture8 object that contains monochrome light map data. ' Set the light map texture as the current texture. Call D3DDevice.SetTexture(0, texLightMap) ' Set the color operation. Call D3DDevice.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1) ' Set argument 1 to the color operation. Call D3DDevice.SetTextureStageState(0, D3DTSS_COLORARG1, _ D3DTA_TEXTURE Or D3DTA_ALPHAREPLICATE)
Because display adapters that do not support destination alpha blending usually do not support multiple texture blending, this example sets the light map as the first texture, which is available on all 3-D accelerator cards. The sample code sets the color operation for the texture's blending stage to blend the texture data with the primitive's existing color. It then selects the first texture and the primitive's existing color as the input data.