I am having an issue where my overlay camera cannot see objects that should be visible in its culling mask, even though the preview windows show that the cameras appear to be working properly.
I’ll try my best to explain it, as I am not allowed to share the specifics.
I have a scene. There is a default layer, and a TransparentFX layer. All objects are on the default layer, except for a single sphere which is on TransparentFX.
I have a camera stack in the scene with 1 base and 1 overlay camera. The base camera has its culling mask set to “everything but TransparentFX” (nothing, everything, transparentFX deselected). The overlay camera exists in the camera stack in the inspector.
The overlay camera is a child of the main camera, in the same position as the main camera. The preview window (the picture-in-picture box in the scene view) for the main camera shows both cameras behaving properly: The main camera shows the whole scene without the TransparentFX object, and the overlay camera shows nothing but the TransparentFX object.
However, in game view, this is not the case. The game view is only rendering objects that the main camera is showing. The postprocessing effects from the overlay camera do appear, if I have that checkbox enabled, but the objects in the layerMask of the overlay camera, which are visible in the preview window, are nowhere to be found in Game View. What is going on? I am using Unity 2022.3.12f1.
I wish I could provide screenshots, but I’d need a second system to do that.
[EDIT] I figured it out: I had the URP Renderer (of type UniversalRendererData) scriptable object have “default” for its opaque layer mask instead of “everything.”
The above scenario will not occur if you just use the default URP asset. In my case, I was using it for a custom renderer feature in a different scene.