Stencil Buffer Depth value inconsistancies with MSAA

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

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.

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):

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.