Legacy Blending Modes and Texture Stages

[Previous] [Next]

Another aspect of alpha blending you need to know about if you're updating a title created using a prior version of Direct3D is the older D3DRENDERSTATE_TEXTUREBLEND render state. Earlier versions of Direct3D introduced the texture-blending render state and its texture-blending modes. The Direct3D documentation presents a set of equivalents of the legacy blending modes you can build using texture stages. These modes, defined by the members of the D3DTEXTUREBLEND enumerated type, are listed below along with an example of how to create the same blend using the texture stage states. I've included this information for those of you who have used these modes or are inheriting legacy code that you need to update to the newest version of DirectX.

D3DTBLEND_ADD

 // g_lpDev is a valid pointer to an IDirect3DDevice7 interface. 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 is a valid pointer to an IDirect3DDevice7 interface. 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 is a valid pointer to an IDirect3DDevice7 interface. 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 is a valid pointer to an IDirect3DDevice7 interface. 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 is a valid pointer to an IDirect3DDevice7 interface. 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); 



Inside Direct3D
Inside Direct3D (Dv-Mps Inside)
ISBN: 0735606137
EAN: 2147483647
Year: 1999
Pages: 131

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net