Game Development Community

Post-multiply alpha (directx coders help!)

by Ian Omroth Hardingham · in General Discussion · 10/06/2009 (11:09 am) · 1 replies

Hey guys.

I'm attempting to render my scene using post-mulitply alpha compositing. I'm setting up using this:

D3DDevice->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE , true);

D3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_INVDESTALPHA);
D3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_DESTALPHA);

D3DDevice->SetRenderState(D3DRS_SRCBLENDALPHA, D3DBLEND_SRCALPHA);
D3DDevice->SetRenderState(D3DRS_DESTBLENDALPHA, D3DBLEND_DESTALPHA);

D3DDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD );

This is kind of almost working, but I have a problem with this line:

D3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_INVDESTALPHA);

It seems that directx always thinks the "destination alpha" is 1, even when it... definitely isn't.

Can anyone help with this?
Thanks,
Ian

#1
10/06/2009 (12:09 pm)
Found the fix - I needed to change the render target format to ARGB (it was XRGB).