Alpha Blending woes

Started by
3 comments, last by Ximmer 22 years, 8 months ago
I''m having a problem getting a Textured polygon to get Alpha blended by the Diffuse Component of a Vertex... Heres some of what I have: #define FVF_Vertex (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX1) struct Vertex { D3DXVECTOR3 Position; D3DXVECTOR3 Normal; D3DCOLOR Diffuse; float u, v; }; but when I Draw an object and set every vertex to D3DCOLOR_ARGB(128, 255, 255, 255) the object is still completely Opaque. I need this to work so I can have Objects fade in and out as well as have an Alpha chanel on the Textures that are on the object. Thanks.
Advertisement
You should enable alpha blending:

  void EnableAlphaBlend(bool flag){  if( flag )  {     m_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);    m_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);    m_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);  }  else  {    m_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,FALSE);  }}  


Then Call EnableAlphaBlend(true) to enable alphablending ro EnableAlphaBlend(false) to diable it. Hope this helps.
Alpha blending is enabled and working well... my problem is that the alpha component of the vertex won''t affect the Final output of the polygon. Only the Alpha channel of the Texture has any affect =(
  		m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );		m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );		m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );		m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );		m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );		m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );		m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );		m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_MODULATE );  
Thanks a ton =) This has been Plauging me for days =)

This topic is closed to new replies.

Advertisement