DirectX SDK

Multipass Texture Blending

Direct3D applications can achieve numerous special effects by applying various textures onto a primitive over the course of multiple rendering passes. The common term for this is multipass texture blending. A typical use for multipass texture blending is to emulate the effects of complex lighting and shading models by applying multiple colors from several different textures. One such application is called light mapping. For more information, see Light Mapping With Textures.

Note  Some devices are capable of applying multiple textures onto primitives in a single pass. 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.

[C++]

To perform multipass texture blending in a C++ application

  1. Set a texture in texture stage 0 by calling the IDirect3DDevice7::SetTexture method.
  2. Select the desired color and alpha blending arguments and operations with the IDirect3DDevice7::SetTextureStageState method. (The default settings are well-suited for multi-pass texture blending.)
  3. Render the appropriate objects in the scene.
  4. Set the next texture in texture stage 0.
  5. Set the D3DRENDERSTATE_SRCBLEND and D3DRENDERSTATE_DESTBLEND render states to adjust the source and destination blending factors as needed. The system will blend the new textures with the existing pixels in the render-target surface according to these parameters.
  6. Repeat Steps 3, 4, and 5 with as many textures as needed.
[Visual Basic]

To perform multipass texture blending in a Visual Basic application

  1. Set a texture in texture stage 0 by calling the Direct3DDevice7.SetTexture method.
  2. Select the desired color and alpha blending arguments and operations with the Direct3DDevice7.SetTextureStageState method. (The default settings are well-suited for multi-pass texture blending.)
  3. Render the appropriate objects in the scene.
  4. Set the next texture in texture stage 0.
  5. Set the D3DRENDERSTATE_SRCBLEND and D3DRENDERSTATE_DESTBLEND render states to adjust the source and destination blending factors as needed. The system will blend the new textures with the existing pixels in the render-target surface according to these parameters.
  6. Repeat Steps 3, 4, and 5 with as many textures as needed.