D3D API - D3DTOP_BLENDDIFFUSEALPHA

D3DTOP_BLENDDIFFUSEALPHA
Linearly blend this texture stage, using the interpolated alpha from each vertex.
D3DTOP_BLENDTEXTUREALPHA
Linearly blend this texture stage, using the alpha from this stage's texture.
D3DTOP_BLENDCURRENTALPHA
Linearly blend this texture stage, using the alpha taken from the previous texture stage.

 

D3DTOP_BLENDFACTORALPHA

Linearly blend this texture stage, using a scalar alpha set with the D3DRS_TEXTUREFACTOR render state.

具体混合方式,查看d3d手册

使用:

  

D3DTOP_BLENDDIFFUSEALPHA: 

  g_pd3dDevice->SetTexture(0, g_pTexture);
  g_pd3dDevice->SetTexture(1, g_pTexture2);

  g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
  g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
  g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);

  g_pd3dDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 0);
  g_pd3dDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_BLENDDIFFUSEALPHA);
  g_pd3dDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
  g_pd3dDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
  g_pd3dDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);

 

D3DTOP_BLENDFACTORALPHA:

  g_pd3dDevice->SetTexture(0, g_pTexture);
  g_pd3dDevice->SetTexture(1, g_pTexture2);

  g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
  g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
  g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);

  g_pd3dDevice->SetRenderState(D3DRS_TEXTUREFACTOR, 0x47ffffff);
  g_pd3dDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_BLENDFACTORALPHA);

  g_pd3dDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 0);
  //g_pd3dDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_BLENDDIFFUSEALPHA);
  g_pd3dDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
  g_pd3dDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
  g_pd3dDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);

 

 

 

你可能感兴趣的:(Blend)