Legacy Blending Modes and Texture Stages

Although Direct3D still supports the texture blending render state, D3DRENDERSTATE_TEXTUREMAPBLEND, the blending modes it offers should not be used in combination with texture stage based texture blending, as the results can be unpredictable. However, you can "build" your own equivalents to the legacy blending modes by using texture stages.

This list shows the legacy blending modes (identified by the members of the D3DTEXTUREBLEND enumerated type), followed by a short example that sets up the same blend by way of texture stage states. (For all examples, the g_lpDev variable is assumed to be a valid pointer to an IDirect3DDevice3 interface):

D3DTBLEND_ADD
g_lpDev->SetTextureStageState(0, COLOROP, D3DTOP_ADD);
g_lpDev->SetTextureStageState(0, COLORARG1, D3DTA_TEXTURE);
g_lpDev->SetTextureStageState(0, COLORARG2, D3DTA_DIFFUSE); 

g_lpDev->SetTextureStageState(0, ALPHAOP, D3DTOP_SELECTARG2); 
g_lpDev->SetTextureStageState(0, ALPHAARG2, D3DTA_DIFFUSE);
 
D3DTBLEND_COPY and D3DTBLEND_DECAL
g_lpDev->SetTextureStageState(0, COLOROP, D3DTOP_SELECTARG1);
g_lpDev->SetTextureStageState(0, COLORARG1, D3DTA_TEXTURE);
 
g_lpDev->SetTextureStageState(0, ALPHAOP, D3DTOP_SELECTARG1);
g_lpDev->SetTextureStageState(0, ALPHAARG2, D3DTA_TEXTURE);
 
D3DTBLEND_DECALALPHA
g_lpDev->SetTextureStageState(0, COLOROP, D3DTOP_BLENDTEXTUREALPHA);
g_lpDev->SetTextureStageState(0, COLORARG1, D3DTA_TEXTURE);
g_lpDev->SetTextureStageState(0, COLORARG2, D3DTA_DIFFUSE);

g_lpDev->SetTextureStageState(0, ALPHAOP, D3DTOP_SELECTARG2); 
g_lpDev->SetTextureStageState(0, ALPHAARG2, D3DTA_DIFFUSE);
 
D3DTBLEND_MODULATE
g_lpDev->SetTextureStageState(0, COLOROP, D3DTOP_MODULATE);
g_lpDev->SetTextureStageState(0, COLORARG1, D3DTA_TEXTURE);
g_lpDev->SetTextureStageState(0, COLORARG2, D3DTA_DIFFUSE); 
 
if ( the_texture_has_an_alpha_channel )
{
    g_lpDev->SetTextureStageState(0, ALPHAOP, D3DTOP_SELECTARG1); 
    g_lpDev->SetTextureStageState(0, ALPHAARG1, D3DTA_TEXTURE);
}
else
{ 
    g_lpDev->SetTextureStageState(0, ALPHAOP, D3DTOP_SELECTARG2); 
    g_lpDev->SetTextureStageState(0, ALPHAARG2, D3DTA_DIFFUSE);
} 
D3DTBLEND_MODULATEALPHA
g_lpDev->SetTextureStageState(0, COLOROP, D3DTOP_MODULATE);
g_lpDev->SetTextureStageState(0, COLORARG1, D3DTA_TEXTURE);
g_lpDev->SetTextureStageState(0, COLORARG2, D3DTA_DIFFUSE); 

g_lpDev->SetTextureStageState(0, ALPHAOP, D3DTOP_MODULATE);
g_lpDev->SetTextureStageState(0, ALPHAARG1, D3DTA_TEXTURE);
g_lpDev->SetTextureStageState(0, ALPHAARG2, D3DTA_DIFFUSE); 
 
D3DTBLEND_DECALMASK and D3DTBLEND_MODULATEMASK
Not supported in DirectX 6.0.