Force Z-Level Respect in Viewports?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By babyblueboxers

I have a world with sprite objects in it. These objects may be a great distance apart but may overlap on screen at some point due to reasons. I have two Viewports for this purpose. I want the Viewports to respect the object’s Z-Levels, regardless of which Viewport is higher/lower in the node tree. As it currently stands, the Viewports are treated like their own canvases and draw the objects like layers in Photoshop.

For example, if I have Object A in Viewport 1, and Object B in Viewport 2.
Object A has a Z level of -10, Object B has a Z level of +10. If Viewport 1 is lower in the scene tree then Object A renders on top of Object B, despite having a lower Z level. I need to avoid this. I need the Z-levels respected regardless of where the Viewport is in the node tree.

This may not be possible at all, or it may have more to do with Cameras or Canvases than Viewports, but it’s a linchpin of my current project and will tank the whole thing if I can’t resolve the visual glitches that result.