Transparent (not blended) objects - what states?

Started by
3 comments, last by jollyjeffers 19 years, 7 months ago
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:

		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.
"Where genius ends, madness begins."Estauns
Advertisement
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
Try these:
    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.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

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
The AP above was me. no idea why it logged me out when I posted that...

Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement