# \[4.15 p2\] MSAA and Alpha2Coverage problem

**URL:** <https://forums.unrealengine.com/t/4-15-p2-msaa-and-alpha2coverage-problem/383502>\
**Category:** Rendering\
**Tags:** msaa, unreal-engine, masked, question\
**Created:** [January 31, 2017, 1:28pm UTC](https://forums.unrealengine.com/t/4-15-p2-msaa-and-alpha2coverage-problem/383502 "2017-01-31T13:28:41Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![HEGI](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hegi/32/1194664_2.png) [@HEGI](https://forums.unrealengine.com/u/HEGI)\
**Post date:** [January 31, 2017, 1:28pm UTC](https://forums.unrealengine.com/t/4-15-p2-msaa-and-alpha2coverage-problem/383502/1 "2017-01-31T13:28:41Z")

</div>

Hello!

The forward renderer is really awesome. But with MSAA and masked materials, too much of the texture is masked out by default. It is worse with 2x MSAA than with 4X.

Here is an image using the UE4 VR template and Epic assets to illustrate the problem.

 ![124315-msaa.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/b/9/1b9ed292872b2d72444a2f96c12c546ac66924b3.jpeg)

To fix this, the opacity mask clip value has to be lowered by a significant amount. So i ended up with a workaround. Changing the _DiscardMaterialWithPixelCoverage_ fuction in _MaterialTemplate.usf_ to adjust the clip values globally, when MSAA is on. Scaling _MaskClip_ by 0.1 fixed the issues.

I’am not sure if this is a bug, but it would be good if this would somehow work by default, so that masked materials look the same with all Anti-Aliasing methods.

Brest Regards

---

<div class="post-metadata">

**Author:** ![0lento\_archive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@0lento\_archive](https://forums.unrealengine.com/u/0lento_archive)\
**Post date:** [January 31, 2017, 8:51pm UTC](https://forums.unrealengine.com/t/4-15-p2-msaa-and-alpha2coverage-problem/383502/2 "2017-01-31T20:51:59Z")

</div>

I noticed this as well. It’s an issue with speedtrees as leaves also get smaller when you go further away from the tree. Effect is so bad that the leaves almost vanish in the end.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_6e7b421a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_6e7b421a](https://forums.unrealengine.com/u/anonymous_user_6e7b421a)\
**Post date:** [February 1, 2017, 8:20pm UTC](https://forums.unrealengine.com/t/4-15-p2-msaa-and-alpha2coverage-problem/383502/3 "2017-02-01T20:20:16Z")

</div>

Hey guys,

So what you are seeing is expected since Alpha to Coverage is not yet supported with MSAA and Forward Rendering. We have plans to get this implemented, but I do not currently have a timeframe as to when that will be. For now, I would use your global clipping value workaround.

We highlighted these unsupported features in the 4.14 Release notes which you can view by following the link I have provided below.

> **[What's New](https://docs.unrealengine.com/5.1/en-US/whats-new/)**
>
> Information about new features in each release of Unreal Engine

Thank you,

---

<div class="post-metadata">

**Author:** ![HEGI](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hegi/32/1194664_2.png) [@HEGI](https://forums.unrealengine.com/u/HEGI)\
**Post date:** [February 2, 2017, 1:51am UTC](https://forums.unrealengine.com/t/4-15-p2-msaa-and-alpha2coverage-problem/383502/4 "2017-02-02T01:51:02Z")

</div>

Thanks for the headsup.

The behaviour of masked materials in 4.15 is different than in 4.14 and Alpha to Coverage is listed as supported feature here. [Forward Shading Renderer in Unreal Engine | Unreal Engine 5.1 Documentation](https://docs.unrealengine.com/latest/INT/Engine/Performance/ForwardRenderer/index.html)

In 4.14 there was no Anti-Aliasing at all on masked materials. And in 4.15 Alpha to Coverage is mentioned alot in the shader code. It just has the bug, of masking out too much from the texture, but the Anti-Aliasing works.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_6e7b421a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_6e7b421a](https://forums.unrealengine.com/u/anonymous_user_6e7b421a)\
**Post date:** [February 2, 2017, 6:48pm UTC](https://forums.unrealengine.com/t/4-15-p2-msaa-and-alpha2coverage-problem/383502/5 "2017-02-02T18:48:42Z")

</div>

Okay, well I am going to get clarification on whether or not it is officially supported in the 4.15 release, but I entered a ticket to have the information clarified and uniform.

Once I get the answer, we can investigate more into the issue you are experiencing. I will say that the large disclaimer at the top of the documentation link you provided applies to all the associated features, so it is expected certain features are not production ready yet.  
Thanks,

---

<div class="post-metadata">

**Author:** ![HEGI](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hegi/32/1194664_2.png) [@HEGI](https://forums.unrealengine.com/u/HEGI)\
**Post date:** [February 3, 2017, 12:16am UTC](https://forums.unrealengine.com/t/4-15-p2-msaa-and-alpha2coverage-problem/383502/6 "2017-02-03T00:16:42Z")

</div>

Thanks! Some clarification would indeed be good. But yea, i understand that the “experimental” applies to the listed features aswell. I’am fine with the workaround right now.

---

<div class="post-metadata">

**Author:** ![HEGI](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hegi/32/1194664_2.png) [@HEGI](https://forums.unrealengine.com/u/HEGI)\
**Post date:** [February 3, 2017, 1:08am UTC](https://forums.unrealengine.com/t/4-15-p2-msaa-and-alpha2coverage-problem/383502/7 "2017-02-03T01:08:11Z")

</div>

Also, here is the simple workaround. A function change in MaterialTemplate.usf . Line 1739 .

```
uint DiscardMaterialWithPixelCoverage(FMaterialPixelParameters MaterialParameters, FPixelMaterialInputs PixelMaterialInputs)
    {
    	ClipLODTransition(MaterialParameters);
    	float OriginalMask = GetMaterialMaskInputRaw(PixelMaterialInputs);
    	float MaskClip = GetMaterialOpacityMaskClipValue();
    
    	if (View.NumSceneColorMSAASamples > 1)
    	{
    		MaskClip = MaskClip * 0.05; //Workaround for Alpha2Coverage
    		
    		float Mask = (OriginalMask - MaskClip) / (1.0 - MaskClip);
    		uint CurrentPixelCoverage = GetDerivativeCoverageFromMask(Mask);

    		clip(float(CurrentPixelCoverage) - 0.5);
    		return CurrentPixelCoverage;
    	}
    	clip(OriginalMask - MaskClip);
    	return 0xF;
    }
```

---

<div class="post-metadata">

**Author:** ![HEGI](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hegi/32/1194664_2.png) [@HEGI](https://forums.unrealengine.com/u/HEGI)\
**Post date:** [February 6, 2017, 11:19pm UTC](https://forums.unrealengine.com/t/4-15-p2-msaa-and-alpha2coverage-problem/383502/9 "2017-02-06T23:19:20Z")

</div>

Great to hear ,thanks!

---

<div class="post-metadata">

**Author:** ![spidershift](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@spidershift](https://forums.unrealengine.com/u/spidershift)\
**Post date:** [February 17, 2017, 9:45pm UTC](https://forums.unrealengine.com/t/4-15-p2-msaa-and-alpha2coverage-problem/383502/10 "2017-02-17T21:45:44Z")

</div>

Thank you for posting a workaround. I tried this and while it helped a little bit the fading problem still seems to exist after the 4.15 update. The pictures you posted were relatively close to the trees but in practice things are much worse when farther away in a more realistic scenario.

I’m wondering if there is some way to disable this new alpha to coverage feature completely? I really like the new renderer especially for MSAA but after this update things just look ridiculous. I’m really surprised this slipped through the cracks because it’s extremely noticeable especially when opening any nature map.

---

<div class="post-metadata">

**Author:** ![andtheand](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@andtheand](https://forums.unrealengine.com/u/andtheand)\
**Post date:** [February 19, 2017, 7:33pm UTC](https://forums.unrealengine.com/t/4-15-p2-msaa-and-alpha2coverage-problem/383502/11 "2017-02-19T19:33:42Z")

</div>

Just found this thread after I posted here:

> **[strange outline against the sky with foliage in 4.15 and MSAA](https://forums.unrealengine.com/questions/564774/strange-outline-against-the-sky-with-foliage-in-41.html)**
>
> Just tried 4.15 because I was eagerly awaiting the ‘alpha to coverage’ implementation for msaa in the forward renderer, which was missing in 4.14. It works nice - all the aliasing is gone but now I have some strange blue outline around the branches...

Is this the same problem? I’m using a BP only project so this workaraound doesn’t work for me…

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_6e7b421a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_6e7b421a](https://forums.unrealengine.com/u/anonymous_user_6e7b421a)\
**Post date:** [February 20, 2017, 4:09pm UTC](https://forums.unrealengine.com/t/4-15-p2-msaa-and-alpha2coverage-problem/383502/12 "2017-02-20T16:09:55Z")

</div>

Hey andtheand,

It does look like your issue could be from MSAA alpha to coverage. We are aware of issues like this, and you we ask you remain patient until we can officially address for an upcoming release.

We have no timeframe, and the only suggestions I have would be to try and edit the masked clipping value within your material, or disabling the Forward Renderer and stick with the default method of Temporal AA.

Thank you,

---

<div class="post-metadata">

**Author:** ![andtheand](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@andtheand](https://forums.unrealengine.com/u/andtheand)\
**Post date:** [February 20, 2017, 7:37pm UTC](https://forums.unrealengine.com/t/4-15-p2-msaa-and-alpha2coverage-problem/383502/13 "2017-02-20T19:37:48Z")

</div>

please give this problem some priority. For every VR project MSAA is essential but can’t be used in any nature environment with this behaviour. Thanks!

---

<div class="post-metadata">

**Author:** ![HEGI](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hegi/32/1194664_2.png) [@HEGI](https://forums.unrealengine.com/u/HEGI)\
**Post date:** [June 14, 2017, 4:08pm UTC](https://forums.unrealengine.com/t/4-15-p2-msaa-and-alpha2coverage-problem/383502/14 "2017-06-14T16:08:57Z")

</div>

Sadly, the workaround does not work anymore in 4.16.

Are there any news on another fix ?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_6e7b421a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_6e7b421a](https://forums.unrealengine.com/u/anonymous_user_6e7b421a)\
**Post date:** [June 15, 2017, 7:10pm UTC](https://forums.unrealengine.com/t/4-15-p2-msaa-and-alpha2coverage-problem/383502/15 "2017-06-15T19:10:20Z")

</div>

This is a workaround to help with the visual banding that appears when using MSAA and Alpha to Coverage, but perhaps it will also help with the masking issues here?

To get a result closer to the deferred renderer, you can make your OpacityMask input into a steeper gradient. For example if you have an OpacityMaskClipValue of .33, you can do a Mul with 5 and then Subtract (.33 \* 5). This will make the OpacityMask gradient steeper, pushing the translucent bands closer together, but keeping the value .33 in the same spot.

There are no updates to this issue as of now, but it is on our roadmap to be improved.

Thanks,

H.

---

<div class="post-metadata">

**Author:** ![HEGI](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hegi/32/1194664_2.png) [@HEGI](https://forums.unrealengine.com/u/HEGI)\
**Post date:** [June 16, 2017, 10:21am UTC](https://forums.unrealengine.com/t/4-15-p2-msaa-and-alpha2coverage-problem/383502/16 "2017-06-16T10:21:29Z")

</div>

Thanks Andrew, this works.

It can also be added to _GetMaterialMaskInputRaw_ in _MaterialTemplate.usf_ to make this global. This means less control ofc. Making a material function is probably the best way.

For people with this issue, you can check for MSAA with a custom material node using _View.NumSceneColorMSAASamples_

I also noticed that it seems to work pretty well with MSAA 4x now without any changes. This is also mentioned in the _CustomAlpha2Coverage_ function in _BasePassPixelShader.usf_ . It says _todo: support non 4xMSAA as well_. So it seems something is moving forward(no pun) there. 🙂

Best Regards
