Difference between revisions of "Blending mode"
From Project X Wiki
(Created page with " == Blending mode == 128 - disable AA 64 - color of pixel is multiplied by target pixel color 1 - additive rendering instead of alpha 2 - diffusion color (col parameter in C...") |
m (Reverted edits by DonaldTurner (talk) to last revision by Zed) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
== Blending mode == | == Blending mode == | ||
− | + | 0 - no blending | |
− | |||
1 - additive rendering instead of alpha | 1 - additive rendering instead of alpha | ||
2 - diffusion color (col parameter in CVertex) adds to texture color, instead of multiplying | 2 - diffusion color (col parameter in CVertex) adds to texture color, instead of multiplying | ||
Line 9: | Line 8: | ||
6 - multiplication & dividing by 2 after | 6 - multiplication & dividing by 2 after | ||
8 - addition, then 127 is subtracted from each component | 8 - addition, then 127 is subtracted from each component | ||
+ | |||
32 - disable alpha channel | 32 - disable alpha channel | ||
+ | 64 - color of pixel is multiplied by target pixel color | ||
+ | 128 - disable AA | ||
it's in groups, flags 0,2,4,6,8, are choosing blending mode (color parameter target), everything else is just flags | 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) | + | |
− | + | 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 ); | |
− | + | }; | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Latest revision as of 09:36, 10 August 2012
Blending mode
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 64 - color of pixel is multiplied by target pixel color 128 - disable AA
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 ); };