Sign in to follow this  

Alpha Channel for TV mixing [Resolved]

This topic is 4285 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

Hi, I'm using DirectX8.1 and creating a 32Bit backbuffer A8R8G8B8 format. I want to blend the RGB component with with a mixture of 32Bit colour info and the 32Bit textures' alpha component. so...
	m_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
	m_pD3DDevice->SetRenderState(D3DRS_SPECULARENABLE , 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( 1, D3DTSS_COLOROP,   D3DTOP_DISABLE );

	m_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP,  D3DTOP_MODULATE  );
	m_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
	m_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
	m_pD3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP,  D3DTOP_DISABLE );
my problem is that the RGB looks good, but the backbuffers' alpha is not blending as I want. I want the alpha to 'OR' with any other alpha that is rendered, thus if a primative is drawn with an alpha of .5 followed by a primative drawn with and alpha of .1 the backbuffer should have a result of .5, at the moment the backbuffer has a value of .1. Any ideas? [Edited by - darrenmarklines on March 20, 2006 7:56:54 AM]

Share this post


Link to post
Share on other sites
I was just pointing out that on certain newer cards you can choose to blend color and alpha different, which is likely something you're going to want. You can emulate this on older cards by using colorwriteenable of RGB, drawing color, then colorwriteenable of A, setting a different blending mode, and drawing your alpha.

As for 'OR'ing the values, I'm not sure how you expect OR to work with float values. Your example is doing a MAX, which may be what you want, in which case you'll want this:

(alpha)blendop = d3dblend_max
(alpha)srcblend = d3dblend_one
(alpha)destblend = d3dblend_one

which will do finalalpha = max(1*newalpha, 1*backbufferalpha).

Check if your card supports seperatealphablendenable (d3dcaps.misccaps & D3DPMISCCAPS_SEPARATEALPHABLEND). If it does enable it, and setup your alpha extra alpha blend modes. If not, you'll need to render in two passes, doing color first, then alpha, and using D3DRS_COLORWRITEENABLE to choose which you're currently affecting.

Share this post


Link to post
Share on other sites

This topic is 4285 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this