Sign in to follow this  
Michael Anthony Wion

Strange alphablending results

Recommended Posts

So I've read up about blend states, and enabled alphablending by adding the following lines to my shader:
[code]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 [i]blending[/i] 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
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 [i]AlphaToCoverageEnable[/i] to [i]TRUE[/i]...
... 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 [i]AlphaToCoverageEnable[/i] disabled, and yet it seemingly does the job for me?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this