m_pD3DDevice->SetTexture(0, NULL);
m_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
m_pD3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE,TRUE);
m_pD3DDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
m_pD3DDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
But that's not working at all for me. It comes up as a pale shade of grey, nothing transparent about it.
Transparent (not blended) objects - what states?
I've got a sphere that I'd like to appear semi-transparent (about 50%, I'll tweak it once I see it in action) so that you can see through it but NOT so that it blends and looks like it's glowing.
I just want to be able to see through it.
I set my vertices diffuse colours with D3DCOLOR_RGBA(255, 255, 255, 128) then I set these states:
I'm not too good with all the alpha blending stuff but, you can try this:
Set your texture states to this:
D3DTSS_ALPHAOP to D3DTOP_SELECTARG1 to
D3DTSS_ALPHAARG1 to D3DTA_DIFFUSE.
Does that work. Is your sphere textured? Thanks
Set your texture states to this:
D3DTSS_ALPHAOP to D3DTOP_SELECTARG1 to
D3DTSS_ALPHAARG1 to D3DTA_DIFFUSE.
Does that work. Is your sphere textured? Thanks
Try these:
This will modulate the diffuse value with the texture value.
D3DDevice.SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); D3DDevice.SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); D3DDevice.SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); D3DDevice.SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); D3DDevice.SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); D3DDevice.SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
This will modulate the diffuse value with the texture value.
Also, a crucial thing that many people slip up on... alpha blended rendering is draw-order dependent.
As such, your grey sphere could be a 50% blend between a black (empty) backbuffer and a white sphere... which is technically correct.
Draw your transparent objects last and/or with back to front draw order.
Jack
As such, your grey sphere could be a 50% blend between a black (empty) backbuffer and a white sphere... which is technically correct.
Draw your transparent objects last and/or with back to front draw order.
Jack
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement