Alpha Transparency DX11

Started by
0 comments, last by b1gjo3 12 years, 7 months ago
Hello everybody, it has been a while since I have asked a question on these forums. Currently I am loading in images that I wish to make the alpha channel transparent when drawing my scene. Here is how i create my blenddesc



D3D11_BLEND_DESC blendDesc;
ZeroMemory( &blendDesc, sizeof( blendDesc ) );
blendDesc.RenderTarget[0].BlendEnable = true;
blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA;
blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;

float blendFactor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };

m_d3dDevice->CreateBlendState( &blendDesc, &alphaBlendState_ );
m_d3dContext->OMSetBlendState( alphaBlendState_, blendFactor, 0xFFFFFFFF );


screenvr.jpg


I cannot figure out why the green "grass" on the bottom is slightly transparent and the blue "clouds" at the top are not.

Here is my pixel shader



float4 PS_Main( PS_Input frag ) : SV_TARGET
{
return colorMap_.Sample( colorSampler_, frag.tex0 );
}


I have tried messing around with the blenddesc a LOT and if I make one change it messes up what im trying to get. Am I missing something completely obvious here?
Advertisement
So I figured out the blue is just too opaque to see through, if I change the color to something lighter it is all partially transparent.

EDIT:

Alright, so apparently irfanview when saving png images makes you select a color to make transparent. It makes that color plus everything else slightly transparent. I opened the images and edited them in photoshop and everything is looking good now.

This topic is closed to new replies.

Advertisement