3D models, Alpha blending

Started by
-1 comments, last by ChainChief 15 years, 4 months ago
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

This topic is closed to new replies.

Advertisement