Sign in to follow this  

3D models, Alpha blending

This topic is 3297 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

This topic is 3297 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this