Flip and/or Mirror Camera not working as expected

Hi Dudes,

I’m kind of stuck with this one. I used this example Unity - Scripting API: MonoBehaviour.OnPreCull() to invert one of multiple cameras in my scene As long as [bool] flip and [bool] mirror are equal, my camera is inverted as expected. But as soon as they differ, I get both, original & mirrored image. May anyone help me on this???

public class FlipAndMirror : MonoBehaviour
    {
    public Camera main_camera;

    public void FlipAndMirrorMainCamera(bool flip, bool mirror)
        {
       
        main_camera.ResetWorldToCameraMatrix();
        main_camera.ResetProjectionMatrix();
       
        if (flip&&mirror)
            {
            main_camera.projectionMatrix = main_camera.projectionMatrix * Matrix4x4.Scale(new Vector3(-1, -1, 1));
            }   
           
        if (!flip&&mirror)   
            {
            main_camera.projectionMatrix = main_camera.projectionMatrix * Matrix4x4.Scale(new Vector3(-1, 1, 1));
            DebugThis("here I am"+ main_camera.projectionMatrix);
           
            }               
        if (flip&&!mirror)   
            {
            main_camera.projectionMatrix = main_camera.projectionMatrix * Matrix4x4.Scale(new Vector3(1, -1, 1));
            }   
           
        if (!flip&&!mirror)       
            {
            main_camera.projectionMatrix = main_camera.projectionMatrix * Matrix4x4.Scale(new Vector3(1, 1, 1));           
            }   
        }
    }

I don’t understand what you mean by “get both original & mirrored”.

thx for your response,

for example: First i call FlipandMirrorMainCamera(true,true), my camera is inverted on both axis and
i see the objects in the scene inverted as well. Now i call FlipandMirrorMainCamera(false,true) and i see my objects inverted, as well as not inverted. The camera shows 2 Objects.

If you’re seeing two images of the same object at the same time, that seems unlikely to be the fault of the code you posted. I don’t think you can get that result just by messing with the projection matrix, and certainly not with a scale.

Is it possible that you have two cameras whose images are compositing?

Setting Clear Flags from Skybox to Solid Color fixed it. But i am still kind of confused.