Jump to content
  • Advertisement
Sign in to follow this  
Estauns

Transparent (not blended) objects - what states?

This topic is 5426 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!