• Advertisement
Sign in to follow this  

Strange alphablending results

This topic is 2113 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:
[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()));
SetGeometryShader(NULL);
SetPixelShader(CompileShader(ps_4_0, TexturePixelShader()));
}
}[/code]
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
Advertisement
Hidden
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 [i]AlphaToCoverageEnable[/i] to [i]TRUE[/i]...
... Except there are some "ghostly" artifacts which occur during certain camera angles, as shown here:
[media]http://youtu.be/jXx27YG7gY4[/media]
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
Sign in to follow this  

  • Advertisement