I'm trying to setup blending state to perform some blending, but for some reason I can't understand how it works, it's always giving me troubles.
My pixel shader returns (0, 0, 0, x), where x is some amount of alpha, basically I just want to make some areas darker. Here's my current blend state setup:
D3D11_BLEND_DESC blendDesc; blendDesc.AlphaToCoverageEnable = FALSE; blendDesc.IndependentBlendEnable = FALSE; blendDesc.RenderTarget[0].BlendEnable = TRUE; blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_COLOR; blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_DEST_COLOR; blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA; blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA; blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;Why I setup it like this? Well I think SRC is new color, DEST is current render target color, so SrcBlend and DestBlend are set to use those colors, SrcBlendAlpha is set to use whatever alpha pixel shader returns, and DestBlendAlpha uses inverse of new alpha. Therefore I believe it'll end up like this:
rt_color = rt_color * (1 - new_color.a) + new_color * new_color.a;
But it doesn't seem to do that.
Could anyone explain me how blending states work and/or help setup it to get it to work like I need?
Thank you in advance.







