Sign in to follow this  
GL3336563

about "AlphaToCoverage"

Recommended Posts

When  i  use  AlphaToCoverage blendstate  i  get  some  bug .  I found  the  alpha  texture edge  has  white  edge,like leaf.

finally I  find  when    the  alpha  texture  render without Opaque blendstate the texture's has one black rectange with the 
valid pixel in other program. But In my  program  when I  use  opaque blendstate  it's  don't have that black rectange  it's whole  white. So  i think  if  I can solve why the texture lost the black Rectange.I can solve this problem.
Who konw  this  is Why?  Thank  you  very much.
I use  WPF  render host  with SharpDX(DirectX11) do this.

  var atcDesc = new BlendStateDescription
            {
                AlphaToCoverageEnable = true,
                IndependentBlendEnable = false,
            };
            atcDesc.RenderTarget[0].IsBlendEnabled = false;
            atcDesc.RenderTarget[0].RenderTargetWriteMask = ColorWriteMaskFlags.All;
            AlphaToCoverageBS = new BlendState(device, atcDesc);

 

I  found AlphaToCoverage Can't render  correctly  in  a  RenderTaget. It  is  only  correct  render  in the  swapchain  directly.So  It  means  I can't uese  any  PostProcess Effect like HDR.    Who  know  if  this  problem  can  solve.

Edited by GL3336563

Share this post


Link to post
Share on other sites

Off the top of my head, that tends to happen when your leaves (or whatever else you have that uses a transparent texture) are rendered out of order, meaning that the edges of the leaves will blend with the background colour of the wrong object (for example your skybox instead of what is immediately behind them).

To solve this you'll have to either ensure all your transparent objects are drawn back-to-front and that your non-transparent objects are drawn in a previous pass, separate from the transparent ones (or you can sort them all but that generally wastes some more time). Another approach is to skip alpha blending and instead just clip pixels whose alpha value is below some threshold from your pixel shader. That looks blockier up close, but since you have no alpha blending and just overwrite pixels with the ones closer to the camera, you don't need to sort all your foliage, which can be a lot of overhead if you have plenty of it.

Share this post


Link to post
Share on other sites


Off the top of my head, that tends to happen when your leaves (or whatever else you have that uses a transparent texture) are rendered out of order, meaning that the edges of the leaves will blend with the background colour of the wrong object (for example your skybox instead of what is immediately behind them).

 

He's using AlphaToCoverage, so the order shouldn't matter. It should be like alpha testing, except for a MSAA render target.

 

I agree with belfegor that it's probably an issue with your texture. The "green-ness" of your leaves needs to extend all the way through the texture, even the transparent bits.

Share this post


Link to post
Share on other sites

 

 

Off the top of my head, that tends to happen when your leaves (or whatever else you have that uses a transparent texture) are rendered out of order, meaning that the edges of the leaves will blend with the background colour of the wrong object (for example your skybox instead of what is immediately behind them).

 
He's using AlphaToCoverage, so the order shouldn't matter. It should be like alpha testing, except for a MSAA render target.
 
I agree with belfegor that it's probably an issue with your texture. The "green-ness" of your leaves needs to extend all the way through the texture, even the transparent bits.

 

Thanks for the whole reply! When I use winform(we usually use it) instead of WPF(use D3DImage) it's

Normal. I use the same code only different renderHost. you can see the difference. I guess WPF is

only support DX9 so When I render the DX11 rendertarget then I convert it to DX9 texture, Maybe this

process lost someting "AlphaToCoverage" need. But i don't know what it is. So my Editer with WPF can't use

this tech now,only can use alphablend. May be this problem can't solve in WPF Maybe can solve. if

someone konw,please help me. Thanks very much. My english is Bad! Sorry...

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