Jump to content

  • Log In with Google      Sign In   
  • Create Account


about "AlphaToCoverage"


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 GL3336563   Members   -  Reputation: 123

Like
0Likes
Like

Posted 25 June 2014 - 04:02 AM

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.

Attached Thumbnails

  • whitoutBlackRectange.png
  • BlackRectange.png
  • MyError.jpg

Edited by GL3336563, 02 July 2014 - 11:18 PM.


Sponsor:

#2 Husbjörn   Members   -  Reputation: 230

Like
0Likes
Like

Posted 26 June 2014 - 11:07 AM

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.



#3 belfegor   Crossbones+   -  Reputation: 2553

Like
0Likes
Like

Posted 26 June 2014 - 11:41 AM

I think it is related how texture is created. Make sure that your "background" color is matching with leaves/branches color on edges

Look at this tutorial for nice explanation: http://www.cgtextures.com/content.php?action=tutorial&name=alphabg



#4 phil_t   Crossbones+   -  Reputation: 3254

Like
0Likes
Like

Posted 26 June 2014 - 11:57 AM


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.



#5 GL3336563   Members   -  Reputation: 123

Like
0Likes
Like

Posted 01 July 2014 - 12:11 AM

 

 

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...

Attached Thumbnails

  • 22.jpg
  • 33.jpg





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS