Blending mode
From Project X Wiki
Blending mode
128 - disable AA 64 - color of pixel is multiplied by target pixel color 0 - no blending 1 - additive rendering instead of alpha 2 - diffusion color (col parameter in CVertex) adds to texture color, instead of multiplying 4 - like 2, but "smooth addition" 6 - multiplication & dividing by 2 after 8 - addition, then 127 is subtracted from each component 32 - disable alpha channel
it's in groups, flags 0,2,4,6,8, are choosing blending mode (color parameter target), everything else is just flags
if (q->blend & 128) { pD3DDevice->SetRenderState( D3DRS_MULTISAMPLEANTIALIAS, FALSE ); } else { pD3DDevice->SetRenderState( D3DRS_MULTISAMPLEANTIALIAS, TRUE ); } }
if (q->blend & 64) { pD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO); pD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCCOLOR); //col } else if (q->blend & 1) //additive/replace { pD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); pD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); //additive } else { pD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); pD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); //aplha-blending };
int difftype = q->blend & 14; if (difftype == 2) //diffusion to addition { pD3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_ADD ); } else if (difftype == 0) { //diffusion to modulation pD3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); } else if (difftype == 4) { //diffusion to smooth addition pD3DDevice->SetTextureStageS pD3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_ADDSMOOTH ); } else if (difftype == 6) { //diffusion to double modulation pD3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE2X ); } else if (difftype == 8) { //diffusion to signed addition pD3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_ADDSIGNED ); };
if (q->blend & 3) { if (q->blend & 32) { pD3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE ); } else { pD3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ); };