I''m doing alpha-testing:
m_Device->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE );
m_Device->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATER );
m_Device->SetRenderState( D3DRS_ALPHAREF, 0 );
m_Device->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
m_Device->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
...and as you can see I''m trying to get it to work based on the alpha values of the individual texels. They are 255 by default but 0 where they''re supposed to be transparent.
I create a 32-bit bitmap in memory whose alpha values are set as such, and load it like:
Result = D3DXCreateTextureFromFileInMemoryEx( m_Device,
FileStream,
BMFile.bfSize,
0,
0,
0,
0,
D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED,
D3DX_FILTER_NONE,
D3DX_FILTER_BOX,
0xFF000000,
NULL,
NULL,
&Texture );
But the alpha values seem to be ignored as only black parts of the texture are transparent. I want the color key to be ignored by setting it to 0x00000000 but nothing is transparent then. It''s only using the color key and not the alpha values. I can''t figure out how to fix this. Can anyone help?
~CGameProgrammer( );
DevImg.net - Post screenshots, comment on others.
Town 3D Engine - A city-rendering 3D engine. Download the demo.