Alpha channel

Started by
2 comments, last by Larry91 13 years, 9 months ago
Hello everybody!
I have a problem with an alpha channel! The mesh that has a texture on the alpha channel is rendered without translucence!

I wanna render a mesh water with an alpha texture!

Here's my code:

// Enable alpha testing	m_pD3DDevice->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE );	m_pD3DDevice->SetRenderState( D3DRS_ALPHAREF, (DWORD)0x000000A0 );	m_pD3DDevice->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL );	m_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );	m_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );	m_pD3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );	//m_pD3DDevice->SetRenderState( D3DRS_ALPHATESTENABLE, false );	m_pD3DDevice->SetRenderState( D3DRS_SRCBLEND , D3DBLEND_SRCALPHA );	m_pD3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );	m_pD3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );	m_pD3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );	m_pD3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );	m_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );	m_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );	m_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );	// Set up sampler states.	m_pD3DDevice->SetSamplerState( 0, D3DSAMP_MINFILTER    , m_MinFilter );	m_pD3DDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER    , m_MagFilter );	m_pD3DDevice->SetSamplerState( 0, D3DSAMP_MIPFILTER    , m_MipFilter );	m_pD3DDevice->SetSamplerState( 0, D3DSAMP_MAXANISOTROPY, m_Anisotropy );	// Set texture / addressing / color ops	m_pD3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );	m_pD3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );	m_pD3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP  , D3DTOP_MODULATE );	m_pD3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
Advertisement
m_pD3DDevice->SetRenderState( D3DRS_ALPHAREF, (DWORD)0x000000A0 );

0xA0 seems very high. Have you tried using a smaller value?

Also, have you tried disabling alpha testing completely?
Yes, but it's not working!
I believe that I solved this pseudo problem!
The true problem consist in alpha sorting, and I don't know how can I get details about meshes for discover if a mesh has alpha!

LE1: How can I get alpha value from a texture?
For materials I tested if diffuse.a is less than 1!

LE2: I solved! 10x a lot guys! I forgot to set my texture format to ARGB! :P

[Edited by - Larry91 on July 5, 2010 6:37:16 AM]

This topic is closed to new replies.

Advertisement