modifying alpha values in runtime
I want to create a fade effect in Direct3D, but it''s not just a regular fade to black/white, but with textures. So the screen will fade in to a texture.
Since I''ll be modifying the alpha value in runtime, I assume I don''t need textures with alpha channel like PNG or TGA. I think I''ll be safe with bitmap, as long as the texture format is A8R8G8B8. But then I don''t know how to change the alpha value of the texture...
What should I do to achieve this?
I have my texture stage states set to the followin' values...
And after you've set texture and vertex buffer, do this...
Then render your vertex buffer normally, and you get 50%
transparent texture (because of the "0x80"). Then you only
modify this 0x80 based on the level of transparency each frame.
[edited by - HaywireGuy on October 9, 2003 5:53:34 AM]
// Enable alpha blendin'...m_lpD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);m_lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);// Primitive color operations.m_lpD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);m_lpD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);// Primitive alpha operations.m_lpD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);m_lpD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);m_lpD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR);
And after you've set texture and vertex buffer, do this...
m_lpD3DDevice->SetRenderState(D3DRS_TEXTUREFACTOR, (DWORD) 0x80FFFFFF);
Then render your vertex buffer normally, and you get 50%
transparent texture (because of the "0x80"). Then you only
modify this 0x80 based on the level of transparency each frame.
[edited by - HaywireGuy on October 9, 2003 5:53:34 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement