Jump to content
  • Advertisement
Sign in to follow this  
Michael Anthony Wion

Strange alphablending results

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

So I've read up about blend states, and enabled alphablending by adding the following lines to my shader:
BlendState AlphaBlendState
AlphaToCoverageEnable = FALSE;
BlendEnable[0] = TRUE;
SrcBlend = SRC_ALPHA;
DestBlend = INV_SRC_ALPHA;
BlendOp = ADD;
SrcBlendAlpha = ZERO;
DestBlendAlpha = ZERO;
BlendOpAlpha = ADD;
RenderTargetWriteMask[0] = 0x0F;
technique10 TextureTechnique
pass pass0
SetBlendState(AlphaBlendState, float4(0.0f, 0.0f, 0.0f, 0.0f), 0xFFFFFFFF);
SetVertexShader(CompileShader(vs_4_0, TextureVertexShader()));
SetPixelShader(CompileShader(ps_4_0, TexturePixelShader()));

And I can tell that some effect is occurring when I set the alpha of a given pixel color to 0.5f, however it's not actually blending with the background. It merely seems to dim the hues of the texture. I opened up my bitmap in DirectX Texture Tool, added an alpha map, and there was no change in results. If I set a color's alpha to 0, it just turns black but you can still see the outlines of the texture overlapping with other textures, instead of being invisible.
Anyone have any suggestions on how to solve this?

Share this post

Link to post
Share on other sites
try setting SrcBlendAlpha to what you have for SrcBlend and DestBlendAlpha to what you have for DestBlend

Share this post

Link to post
I'm not rendering anything except a batch of sprites on a clear backbuffer.
I did however manage to get the alpha channel to kick in by using a png image and setting AlphaToCoverageEnable to TRUE...
... Except there are some "ghostly" artifacts which occur during certain camera angles, as shown here:
Luckily from what I can tell so far, this doesn't occur with my dds format sprites.
What I don't understand is why every online tutorial/resource I've scrounged up have AlphaToCoverageEnable disabled, and yet it seemingly does the job for me?

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!