Bump Mapping Renderstates
Technical Documentation
Bump Mapping (Emboss, 3-pass) // Rendering Pass #1
g_pDevice->SetRenderState( D3DRENDERSTATE_ALPHABLENDENABLE, FALSE );
g_pDevice->SetRenderState( D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE );
g_pDevice->SetRenderState( D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO );
g_pDevice->SetRenderState( D3DRENDERSTATE_WRAP0, D3DWRAP_U | D3DWRAP_V );
g_pDevice->SetRenderState( D3DRENDERSTATE_WRAP1, D3DWRAP_U | D3DWRAP_V );
// bump height texture
g_pDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
g_pDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
g_pDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTFG_LINEAR );
g_pDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTFG_LINEAR );
g_pDevice->SetTextureStageState( 0, D3DTSS_MIPFILTER, D3DTFP_POINT );
g_pDevice->SetTextureStageState( 0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP );
g_pDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
g_pDevice->SetTexture( 0, m_hTexture1 );
g_pDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
g_pDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
// Rendering Pass #2
g_pDevice->SetRenderState( D3DRENDERSTATE_ALPHABLENDENABLE, TRUE );
g_pDevice->SetRenderState( D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE );
g_pDevice->SetRenderState( D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE );
g_pDevice->SetRenderState( D3DRENDERSTATE_WRAP0, D3DWRAP_U | D3DWRAP_V );
g_pDevice->SetRenderState( D3DRENDERSTATE_WRAP1, D3DWRAP_U | D3DWRAP_V );
// inverted bump height texture
g_pDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
g_pDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
g_pDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTFG_LINEAR );
g_pDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTFG_LINEAR );
g_pDevice->SetTextureStageState( 0, D3DTSS_MIPFILTER, D3DTFP_POINT );
g_pDevice->SetTextureStageState( 0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP );
g_pDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
g_pDevice->SetTexture( 0, m_hTexture2 );
g_pDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
g_pDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
// Rendering Pass #3
g_pDevice->SetRenderState( D3DRENDERSTATE_ALPHABLENDENABLE, TRUE );
g_pDevice->SetRenderState( D3DRENDERSTATE_SRCBLEND, D3DBLEND_DESTCOLOR );
g_pDevice->SetRenderState( D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR );
g_pDevice->SetRenderState( D3DRENDERSTATE_WRAP0, D3DWRAP_U | D3DWRAP_V );
g_pDevice->SetRenderState( D3DRENDERSTATE_WRAP1, D3DWRAP_U | D3DWRAP_V );
// base texture
g_pDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
g_pDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
g_pDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTFG_LINEAR );
g_pDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTFG_LINEAR );
g_pDevice->SetTextureStageState( 0, D3DTSS_MIPFILTER, D3DTFP_POINT );
g_pDevice->SetTextureStageState( 0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP );
g_pDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
g_pDevice->SetTexture( 0, m_hTexture3 );
g_pDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
g_pDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
Bump Mapping (Emboss, 2-pass) // Rendering Pass #1
g_pDevice->SetRenderState( D3DRENDERSTATE_ALPHABLENDENABLE, FALSE );
g_pDevice->SetRenderState( D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE );
g_pDevice->SetRenderState( D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO );
g_pDevice->SetRenderState( D3DRENDERSTATE_WRAP0, D3DWRAP_U | D3DWRAP_V );
g_pDevice->SetRenderState( D3DRENDERSTATE_WRAP1, D3DWRAP_U | D3DWRAP_V );
// bump texture
g_pDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
g_pDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
g_pDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTFG_LINEAR );
g_pDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTFG_LINEAR );
g_pDevice->SetTextureStageState( 0, D3DTSS_MIPFILTER, D3DTFP_POINT );
g_pDevice->SetTextureStageState( 0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP );
g_pDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 1 );
g_pDevice->SetTexture( 0, m_hTexture1 );
// inverted bump texture
g_pDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_ADD );
g_pDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
g_pDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
g_pDevice->SetTextureStageState( 1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
g_pDevice->SetTextureStageState( 1, D3DTSS_ALPHAARG2, D3DTA_CURRENT );
g_pDevice->SetTextureStageState( 1, D3DTSS_MINFILTER, D3DTFG_LINEAR );
g_pDevice->SetTextureStageState( 1, D3DTSS_MAGFILTER, D3DTFG_LINEAR );
g_pDevice->SetTextureStageState( 1, D3DTSS_MIPFILTER, D3DTFP_POINT );
g_pDevice->SetTextureStageState( 1, D3DTSS_ADDRESS, D3DTADDRESS_WRAP );
g_pDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 0 );
g_pDevice->SetTexture( 1, m_hTexture2 );
g_pDevice->SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_DISABLE );
g_pDevice->SetTextureStageState( 2, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
// Rendering Pass #2
g_pDevice->SetRenderState( D3DRENDERSTATE_ALPHABLENDENABLE, TRUE );
g_pDevice->SetRenderState( D3DRENDERSTATE_SRCBLEND, D3DBLEND_DESTCOLOR );
g_pDevice->SetRenderState( D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR );
g_pDevice->SetRenderState( D3DRENDERSTATE_WRAP0, D3DWRAP_U | D3DWRAP_V );
g_pDevice->SetRenderState( D3DRENDERSTATE_WRAP1, D3DWRAP_U | D3DWRAP_V );
// base texture
g_pDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
g_pDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
g_pDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTFG_LINEAR );
g_pDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTFG_LINEAR );
g_pDevice->SetTextureStageState( 0, D3DTSS_MIPFILTER, D3DTFP_POINT );
g_pDevice->SetTextureStageState( 0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP );
g_pDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
g_pDevice->SetTexture( 0, m_hTexture3 );
g_pDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
g_pDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
Bump Mapping (Emboss, 1-pass) // Rendering Pass #1
g_pDevice->SetRenderState( D3DRENDERSTATE_ALPHABLENDENABLE, TRUE );
g_pDevice->SetRenderState( D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA );
g_pDevice->SetRenderState( D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO );
g_pDevice->SetRenderState( D3DRENDERSTATE_WRAP0, D3DWRAP_U | D3DWRAP_V );
g_pDevice->SetRenderState( D3DRENDERSTATE_WRAP1, D3DWRAP_U | D3DWRAP_V );
// base texture on color unit, bump texture on alpha unit
g_pDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE2X );
g_pDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
g_pDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTFG_LINEAR );
g_pDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTFG_LINEAR );
g_pDevice->SetTextureStageState( 0, D3DTSS_MIPFILTER, D3DTFP_POINT );
g_pDevice->SetTextureStageState( 0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP );
g_pDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 1 );
g_pDevice->SetTexture( 0, m_hTexture1 );
// base texture on color unit, bump texture on alpha unit
g_pDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_SELECTARG2 );
g_pDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
g_pDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_ADDSIGNED );
g_pDevice->SetTextureStageState( 1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE | D3DTA_COMPLEMENT );
g_pDevice->SetTextureStageState( 1, D3DTSS_ALPHAARG2, D3DTA_CURRENT );
g_pDevice->SetTextureStageState( 1, D3DTSS_MINFILTER, D3DTFG_LINEAR );
g_pDevice->SetTextureStageState( 1, D3DTSS_MAGFILTER, D3DTFG_LINEAR );
g_pDevice->SetTextureStageState( 1, D3DTSS_MIPFILTER, D3DTFP_POINT );
g_pDevice->SetTextureStageState( 1, D3DTSS_ADDRESS, D3DTADDRESS_WRAP );
g_pDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 0 );
g_pDevice->SetTexture( 1, m_hTexture1 );
g_pDevice->SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_DISABLE );
g_pDevice->SetTextureStageState( 2, D3DTSS_ALPHAOP, D3DTOP_DISABLE );