• Advertisement


This topic is now archived and is closed to further replies.

modifying alpha values in runtime

This topic is 5310 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 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?

Share this post

Link to post
Share on other sites
I have my texture stage states set to the followin' values...

// Enable alpha blendin'...

m_lpD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);

// 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]

Share this post

Link to post
Share on other sites

  • Advertisement