Jump to content
  • Advertisement
Sign in to follow this  

Alpha Channel for TV mixing [Resolved]

This topic is 4477 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->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
Thanks for your help Namethatnobodyelsetook,

My solution, because of dx8.1, was to write the RGB and Alpha in seperate passes using D3DRS_COLORWRITEENABLE, then use an apropriate blend mode.


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!