Bypassing Camera priority (RenderObjects)?

I have 2D sidescroller where the background (Behind everything) needs to be rendered orthographically. The rest of the scene is rendered with a perspective camera that has an overlay of another perspective camera. The issue is, there is custom fog in the scene that needs the same background that the orthographic camera is rendering to render correctly but the fog itself cannot be rendered orthographically. So no matter how many cameras or overlay cameras I use, the fog will always be rendered incorrectly as the background must be rendered orthographically but the fog relies on this background and needs it rendered prospectively. The perspective cameras have a literal void behind them without the orthographic cameras background, so the perspective camera and more importantly the fog itself sees nothing behind it which causes it to render incorrectly, I need to make the fog think there is something there even though the perspective camera which renders the fog has masks which make it so there is just a void behind.

What I am trying to figure out is if there is a way to render a background prospectively that then is overwritten by the orthographic camera even though the orthographic camera sees the lowest priority in rendering. So, even though that perspective camera would have a higher priority, keep the background as a lower priority in rendering, that way, the fog can be rendered as if the background is indeed there prospectively and then the orthographic camera can render the background orthographically just right in front of the perspective background.

So somehow → render background prospectively for the first time, → render orthographically the same background which overlaps it completely, → render my perspective camera and its overlay which will render over that background with whatever objects are in scene, fog is then rendered but instead of seeing void since that is what has been written, it sees a perspective background.

The main issue is there is no way for me to do this without putting the background on the perspective cameras which will just overwrite the orthographic cameras background anyway. I was trying to use RenderObjects to accomplish this.

One possible solution is to use a RenderTexture. You could create a new camera that renders the background orthographically to a RenderTexture, and then use that RenderTexture as the background for your perspective camera.

Here’s how you could set this up:

  1. Create a new RenderTexture in your
    project. Make sure it has the same
    aspect ratio as your game window.

  2. Create a new camera in your scene,
    and set its Clear Flags to “Solid
    Color”. Set the background color to
    black (or whatever color you want
    your background to be).

  3. Set the new camera’s Projection to
    Orthographic, and adjust the Size
    and Position so that it covers the
    entire scene.

  4. Set the new camera’s Culling Mask to
    only include the layers that you
    want to appear in the background.

  5. Create a new Material in your
    project, and assign the
    RenderTexture to its Main Texture

  6. Assign the new Material to a new
    Quad object in your scene. This Quad
    should be positioned in front of the
    perspective camera, and should cover
    the entire screen.

  7. Create a new layer in your project,
    and assign it to the objects that
    should appear in front of the

  8. Set the perspective camera’s Culling
    Mask to exclude the layer containing
    the background objects.

  9. Render the orthographic camera to
    the RenderTexture using the camera’s
    targetTexture property.

  10. Use the new Material and Quad to
    display the RenderTexture as the
    background for the perspective

With this setup, the orthographic camera will render the background objects to the RenderTexture, and the perspective camera will render the foreground objects on top of the RenderTexture. The fog should now be able to see the background correctly, even though it’s being rendered orthographically.