Jump to content
  • Advertisement
Sign in to follow this  
ChainChief

3D models, Alpha blending

This topic is 3636 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 am having problems making 3D models semi transparent with Direct3D lighting enabled. By disabeling the lights, I can supply an ARGB color in the vertex structure, and set the render states to allow alpha blending. But when using lights, the material does that job. So I figured the alpha channel would be coded there, but I cant get it to work. Currently I have lights enabled and the material struct set by the device. I also have a modeled cube rotating around the x and y axis. The program runs with ~80% ambient light shining on the cube, but no transparency occurs. I have tried various values for the alpha channel of the material including 0, but this has no effect. The render states I have set are: m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE ); m_pd3dDevice->SetRenderState( D3DRS_AMBIENT, D3DCOLOR_XRGB (200,200,200) ); m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ); m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE); m_pd3dDevice->SetRenderState( D3DRS_NORMALIZENORMALS, TRUE); m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE); m_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); m_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); m_pd3dDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); The code for the material: D3DMATERIAL9 material; ZeroMemory(&material, sizeof(D3DMATERIAL9)); material.Diffuse.r = material.Ambient.r = 1.0f; material.Diffuse.g = material.Ambient.g = 1.0f; material.Diffuse.b = material.Ambient.b = 1.0f; material.Diffuse.a = material.Ambient.a = 0.1f; m_pd3dDevice->SetMaterial(&material); Thanks in advance for any help, Jacob

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • 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!