Disabling Camera MSAA has no effect if a later Camera has MSAA enabled

Hi, I believe I’ve found some undocumented behavior regarding Camera MSAA settings in the built-in rendering pipeline, and I can’t figure out a workaround. For context, my project has 2 cameras:

  1. The Background camera (Depth 0), which draws screen-space outlines using the DepthNormals texture.
  2. The Foreground camera (Depth 1), which has no post-processing, but needs MSAA because it includes animated meshes.

As is visible in this image, the background is rendering with MSAA despite the camera settings, causing some pixels from meshes to extend beyond the edges determined by the DepthNormals texture:

Here, it is seen working correctly (by disabling MSAA on the Foreground camera):

From the Frame Debugger’s “Resolve AA” step it’s clear that MSAA is causing the pixel bleed. Additionally, it should be noted that the Camera MSAA setting does work if the camera depths are switched (i.e. the camera with MSAA turned on is earlier in the render pipeline).

Unfortunately, in order to render the foreground correctly I must draw it after the background (to preserve depth information), so I’m at a loss for workarounds. Any ideas? Is Unity working as intended here?

After further investigation, it seems the reason this happens is that MSAA sample count is not a “per-camera” setting at all. Behind the scenes, it is a render target setting. As a result, the workaround is to directly manipulate the render target for each camera using Camera.targetTexture, and to interpret the results of each camera render manually (using Graphics.Blit instead of the Camera Depth system) on a placeholder camera with Culling Mask = None.