Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Ximmer

Alpha Blending woes

This topic is 6289 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 =(

Share this post


Link to post
Share on other sites
  

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 );

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!