Multipass Texture Blending

Direct3D applications can achieve numerous special effects by applying many textures onto a primitive in more than one pass. The common term for this is multipass texture blending. A typical use for multipass texture blending is to apply shadows to primitives in addition to whatever textures they might normally have. For more information, see Light Mapping With Textures.

All Direct3D device interfaces support multipass texture blending. Beginning with the IDirect3DDevice3 interface, DirectX is also able to apply multiple textures to primitives in a single pass, if the user's hardware supports it. For details, see Multiple Texture Blending.

If your user's hardware does not support multiple texture blending, your application can use multipass texture blending to achieve the same visual effects. However, it will not be able to sustain the frame rates that are possible when using multiple texture blending.

Applications enable multipass texture blending by invoking the IDirect3DDevice3::SetRenderState method, and passing the enumerated value D3DRENDERSTATE_ALPHABLENDENABLE as the value of the first parameter. Pass TRUE as the value of the second parameter to enable texture blending, or FALSE to disable it.

Once texture blending is enabled, your application should set the source and destination blending factors based on the effect you want to achieve. For more information on the source and destination blending factors, see Alpha Texture Blending. Applications control the source blending factors by calling the IDirect3DDevice3::SetRenderState and passing it the enumerated value D3DRENDERSTATE_SRCBLEND as the value of the first parameter. Your program can set the destination blending factor by passing D3DRENDERSTATE_DESTBLEND as the value of the first parameter to IDirect3DDevice3::SetRenderState. In either case, the second parameter must be a member of the D3DBLEND enumerated type.

Applications set the blending operation by passing D3DRENDERSTATE_TEXTUREMAPBLEND as the value of the first parameter in a call to IDirect3DDevice3::SetRenderState. The second parameter must be a member of the D3DTEXTUREBLEND enumerated type.

On each pass, your application must set the current texture. Its texel colors will be blended with the existing pixel colors in the frame buffer. For information on setting the current texture, see Current Texture.