I've been working on a Direct3D game run for a while now and I've come across an issue with alpha blending that I don't quite know how to solve.
I've set my render states like this
// both sides of the triangles
d3ddev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
//Set render states
d3ddev->SetRenderState(D3DRS_LIGHTING, FALSE);// turn off the 3D lighting
//make it so things color can fade
d3ddev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
d3ddev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
d3ddev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
//-------------------------------------------------------------
d3ddev->SetRenderState(D3DRS_ZENABLE, TRUE); // turn on the z-buffer
d3ddev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
Now at first I thought everything was perfectly fine, things that where transparent in my png file would go on screen transparent, but I later found out that they will only be transparent to things they have been rendered after, so if i render a see through a space ship, and then a red cube and then an asteroid and put the red cube in front of both the space ship and the asteroid, only the space ship will be visible with a red tinge, the asteroid will be completely blocked out. Does anyone know why this is happening and how it can be solved?