Jump to content
Site Stability Read more... ×
  • Advertisement
Sign in to follow this  

DX11 Alpha Transparency DX11

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

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 );


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?

Share this post

Link to post
Share on other sites
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.


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.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!