Original Post
Hello,
So I've been trying to fool around with transparent materials a bit and have a small problem.
I used the following code from msdn site:
ZeroMemory(&material, sizeof(D3DMATERIAL9)); // clear out the struct for use
material.Diffuse = D3DXCOLOR(1.0f, 0.4f, 0.0f, 1.0f); // Alpha purpusely set to opaque
material.Ambient = D3DXCOLOR(1.0f, 0.4f, 0.0f, 1.0f); // because that's the odd behaviour
material.Emissive = D3DXCOLOR(1.0f, 0.4f, 0.0f, 1.0f); // I want to solve
material.Specular = D3DXCOLOR(1.0f, 0.4f, 0.0f, 1.0f);
// Enable alpha blending.
d3ddev->SetRenderState(D3DRS_ALPHABLENDENABLE,
TRUE);
// Set the source blend state.
d3ddev->SetRenderState(D3DRS_SRCBLEND,
D3DBLEND_SRCCOLOR);
// Set the destination blend state.
d3ddev->SetRenderState(D3DRS_DESTBLEND,
D3DBLEND_INVSRCCOLOR);
d3ddev->SetRenderState( D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL ); // Tell D3D to get Alpha from material
d3ddev->SetMaterial(&material); // set the globably-used material to &material
OK so I DID in fact achieve my goal of transparency and see through the objects behind BUT... not with as much flexibility as I expected. I can't seem to regulate the amount of transparency that I want and even with 100% opaque values my object is still fully see-through.
So I've been trying to fool around with transparent materials a bit and have a small problem.
I used the following code from msdn site:
ZeroMemory(&material, sizeof(D3DMATERIAL9)); // clear out the struct for use
material.Diffuse = D3DXCOLOR(1.0f, 0.4f, 0.0f, 1.0f); // Alpha purpusely set to opaque
material.Ambient = D3DXCOLOR(1.0f, 0.4f, 0.0f, 1.0f); // because that's the odd behaviour
material.Emissive = D3DXCOLOR(1.0f, 0.4f, 0.0f, 1.0f); // I want to solve
material.Specular = D3DXCOLOR(1.0f, 0.4f, 0.0f, 1.0f);
// Enable alpha blending.
d3ddev->SetRenderState(D3DRS_ALPHABLENDENABLE,
TRUE);
// Set the source blend state.
d3ddev->SetRenderState(D3DRS_SRCBLEND,
D3DBLEND_SRCCOLOR);
// Set the destination blend state.
d3ddev->SetRenderState(D3DRS_DESTBLEND,
D3DBLEND_INVSRCCOLOR);
d3ddev->SetRenderState( D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL ); // Tell D3D to get Alpha from material
d3ddev->SetMaterial(&material); // set the globably-used material to &material
OK so I DID in fact achieve my goal of transparency and see through the objects behind BUT... not with as much flexibility as I expected. I can't seem to regulate the amount of transparency that I want and even with 100% opaque values my object is still fully see-through.