# Stencil Buffer Depth value inconsistancies with MSAA

**URL:** <https://forums.unrealengine.com/t/stencil-buffer-depth-value-inconsistancies-with-msaa/394598>\
**Category:** Rendering\
**Tags:** buffer, Post-Processing, stencil, unreal-engine, Rendering, question\
**Created:** [May 25, 2017, 6:44pm UTC](https://forums.unrealengine.com/t/stencil-buffer-depth-value-inconsistancies-with-msaa/394598 "2017-05-25T18:44:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mordentral](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mordentral](https://forums.unrealengine.com/u/mordentral)\
**Post date:** [May 25, 2017, 6:44pm UTC](https://forums.unrealengine.com/t/stencil-buffer-depth-value-inconsistancies-with-msaa/394598/1 "2017-05-25T18:44:52Z")

</div>

There appears to be some inconsistency or precision issues with scene depth and stencil buffer depth values when using MSAA instead of FXAA/TAA.

For example, Tom Loomans post process outline material outlined here: [Multi-color Outline Post Process - Tom Looman](http://www.tomlooman.com/multi-color-outline-post-process-in-unreal-engine-4/)

Will work as intended with TAA or FXAA, however has edge cases where the depth comparison between the Scene Depth node and the Custom/Stencil depth (for occlusion detection) is slightly different on thin geometry or edges (seems like precision issues) counting visible pixels as occluded in the check.

Also a simple post process that renders a flat color instead of scene texture of objects in the custom depth buffer that are occluded will show artifacts with MSAA on thin geometry and at edges but will be clean with the other AA options.

I am unaware of if this is an expected issue with MSAA because of how it re-samples the scene but figured I should bring it up.

---

<div class="post-metadata">

**Author:** ![Tobias\_Tobasco](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tobias_tobasco/32/1194646_2.png) [@Tobias\_Tobasco](https://forums.unrealengine.com/u/Tobias_Tobasco)\
**Post date:** [August 13, 2017, 8:53pm UTC](https://forums.unrealengine.com/t/stencil-buffer-depth-value-inconsistancies-with-msaa/394598/2 "2017-08-13T20:53:42Z")

</div>

I’m having the same issue and it’s annoying, because i have to use FXAA instead of the awesome MSAA, just because of this issue…  
My thread is here (also no answer so far):

> **[MSAA not working with custom Post Processing (CustomDepth)](https://forums.unrealengine.com/questions/530926/msaa-not-working-with-custom-post-processing-custo.html)**
>
> Hello, i have a custom outline post processing material in my project (PC,XB1,PS4), which uses stencils and custom depth. It's not working with MSAA (because of the custom depth i guess?). Is there anything i can do to make it work? If not, will...

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_a2fdf5a6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a2fdf5a6](https://forums.unrealengine.com/u/anonymous_user_a2fdf5a6)\
**Post date:** [January 16, 2019, 6:26pm UTC](https://forums.unrealengine.com/t/stencil-buffer-depth-value-inconsistancies-with-msaa/394598/3 "2019-01-16T18:26:44Z")

</div>

I think that maybe you could make a postprocessing material that does antialiasing instead of using MSAA, so you can solve those issues you have with that AA method on the custom one (unless you want some sort of supersampling; in that case I don´t know) ; If you don´t know where to start, maybe you can use a kernel that looks for differences in the stencil buffer and world normal to blend pixel colors.
