Right eye projection matrix is incorrect VR stereo portal

Has anyone figured out how to get the correct left and right eye projection matrixes in Unity? My left eye looks exactly correct, however, my right eye projection matrix makes it so that objects warp when moving my HMD. I am using the Oculus Quest 2 with the OVR dev kit.

I am trying to make a portal effect, and when I close my left eye it looks perfect. Here is a video, but it doesn’t demonstrate the problem (as it only occurs in the left eye).
Video Example

Here is the code that I am using to get the projection matrixes for each eye:

// left eye projection matrix
OVRManager.instance.gameObject.GetComponent<OVRCameraRig>().leftEyeCamera.GetStereoProjectionMatrix(Camera.StereoscopicEye.Left)
// right eye projection matrix
OVRManager.instance.gameObject.GetComponent<OVRCameraRig>().rightEyeCamera.GetStereoProjectionMatrix(Camera.StereoscopicEye.Right)

Here is what I am doing to render the eyes to textures (it is a modified version of the HTC Stereo Rendering package)

private void RenderToTwoStereoTextures(VRRenderEventDetector detector)
            {
                // get eye poses
                var leftEyeOffset = StereoRenderManager.Instance.paramFactory.GetEyeSeperation(0);
                var leftEyeRotation = StereoRenderManager.Instance.paramFactory.GetEyeLocalRotation(0);
    
                var rightEyeOffset = StereoRenderManager.Instance.paramFactory.GetEyeSeperation(1);
                var rightEyeRotation = StereoRenderManager.Instance.paramFactory.GetEyeLocalRotation(1);
    
                // render stereo textures
                RenderEye(
                    leftEyeOffset, leftEyeRotation, 
                    leftProjMatrix, detector.unityCamera.worldToCameraMatrix, 
                    leftEyeTexture, "_LeftEyeTexture");
    
                var rightEyeWorldToCameraMatrix = detector.unityCamera.worldToCameraMatrix;
                rightEyeWorldToCameraMatrix.m03 -= 2.0f * Mathf.Abs(leftEyeOffset.x);
    
                RenderEye(
                    rightEyeOffset, rightEyeRotation,
                    rightProjMatrix, rightEyeWorldToCameraMatrix,
                    rightEyeTexture, "_RightEyeTexture");
            }

        private void RenderToTwoStereoTextures(VRRenderEventDetector detector)
        {
            // get eye poses
            var leftEyeOffset = StereoRenderManager.Instance.paramFactory.GetEyeSeperation(0);
            var leftEyeRotation = StereoRenderManager.Instance.paramFactory.GetEyeLocalRotation(0);

            var rightEyeOffset = StereoRenderManager.Instance.paramFactory.GetEyeSeperation(1);
            var rightEyeRotation = StereoRenderManager.Instance.paramFactory.GetEyeLocalRotation(1);

            // render stereo textures
            RenderEye(
                leftEyeOffset, leftEyeRotation, 
                leftProjMatrix, detector.unityCamera.worldToCameraMatrix, 
                leftEyeTexture, "_LeftEyeTexture");

            var rightEyeWorldToCameraMatrix = detector.unityCamera.worldToCameraMatrix;
            rightEyeWorldToCameraMatrix.m03 -= 2.0f * Mathf.Abs(leftEyeOffset.x);

            RenderEye(
                rightEyeOffset, rightEyeRotation,
                rightProjMatrix, rightEyeWorldToCameraMatrix,
                rightEyeTexture, "_RightEyeTexture");
        }


        private Vector4 GetCameraSpacePlane(Camera cam, Vector3 pt, Vector3 normal)
        {
            Matrix4x4 m = cam.worldToCameraMatrix;
            Vector3 camSpacePt = m.MultiplyPoint(pt);
            Vector3 camSpaceNormal = m.MultiplyVector(normal).normalized;
            return new Vector4(
                camSpaceNormal.x,
                camSpaceNormal.y,
                camSpaceNormal.z,
                -Vector3.Dot(camSpacePt, camSpaceNormal));
        }

        private Vector4 GetObliqueNearClipPlane()
        {
            var clipPlaneCameraSpace = Vector4.zero;
            if (!isMirror)
            {
                clipPlaneCameraSpace = GetCameraSpacePlane(stereoCameraEye, anchorPos, anchorForward);
            }
            else
            {
                // get reflection plane -- assume +y as normal
                float d = -Vector3.Dot(canvasOriginUp, canvasOriginPos) - reflectionOffset;
                Vector4 reflectionPlane = new Vector4(canvasOriginUp.x, canvasOriginUp.y, canvasOriginUp.z, d);

                clipPlaneCameraSpace = GetCameraSpacePlane(stereoCameraEye, canvasOriginPos, reflectionPlane);
            }

            return clipPlaneCameraSpace;
        }

        private Rect GetScissorRect(Matrix4x4 mat)
        {
            var renderer = GetComponent<Renderer>();
            Vector3 cen = renderer.bounds.center;
            Vector3 ext = renderer.bounds.extents;
            Vector3[] extentPoints = new Vector3[8]
            {
                 WorldPointToViewport(mat, new Vector3(cen.x-ext.x, cen.y-ext.y, cen.z-ext.z)),
                 WorldPointToViewport(mat, new Vector3(cen.x+ext.x, cen.y-ext.y, cen.z-ext.z)),
                 WorldPointToViewport(mat, new Vector3(cen.x-ext.x, cen.y-ext.y, cen.z+ext.z)),
                 WorldPointToViewport(mat, new Vector3(cen.x+ext.x, cen.y-ext.y, cen.z+ext.z)),
                 WorldPointToViewport(mat, new Vector3(cen.x-ext.x, cen.y+ext.y, cen.z-ext.z)),
                 WorldPointToViewport(mat, new Vector3(cen.x+ext.x, cen.y+ext.y, cen.z-ext.z)),
                 WorldPointToViewport(mat, new Vector3(cen.x-ext.x, cen.y+ext.y, cen.z+ext.z)),
                 WorldPointToViewport(mat, new Vector3(cen.x+ext.x, cen.y+ext.y, cen.z+ext.z))
            };

            bool invalidFlag = false;
            Vector2 min = extentPoints[0];
            Vector2 max = extentPoints[0];
            foreach (Vector3 v in extentPoints)
            {
                // if v.z < 0 means this projection is unreliable
                if (v.z < 0)
                {
                    invalidFlag = true;
                    break;
                }

                min = Vector2.Min(min, v);
                max = Vector2.Max(max, v);
            }

            if (invalidFlag)
            {
                return fullViewport;
            }
            else
            {
                min = Vector2.Max(min, Vector2.zero);
                max = Vector2.Min(max, Vector2.one);
                return new Rect(min.x, min.y, max.x - min.x, max.y - min.y);
            }
        }

        private Matrix4x4 GetScissorMatrix(Rect rect)
        {
            Matrix4x4 m2 = Matrix4x4.TRS(
                new Vector3((1 / rect.width - 1), (1 / rect.height - 1), 0),
                Quaternion.identity,
                new Vector3(1 / rect.width, 1 / rect.height, 1));

            Matrix4x4 m3 = Matrix4x4.TRS(
                new Vector3(-rect.x * 2 / rect.width, -rect.y * 2 / rect.height, 0),
                Quaternion.identity,
                Vector3.one);

            return m3 * m2;
        }

        private Vector3 WorldPointToViewport(Matrix4x4 mat, Vector3 point)
        {
            Vector3 result;
            result.x = mat.m00 * point.x + mat.m01 * point.y + mat.m02 * point.z + mat.m03;
            result.y = mat.m10 * point.x + mat.m11 * point.y + mat.m12 * point.z + mat.m13;
            result.z = mat.m20 * point.x + mat.m21 * point.y + mat.m22 * point.z + mat.m23;

            float a = mat.m30 * point.x + mat.m31 * point.y + mat.m32 * point.z + mat.m33;
            a = 1.0f / a;
            result.x *= a;
            result.y *= a;
            result.z = a;

            point = result;
            point.x = (point.x * 0.5f + 0.5f);
            point.y = (point.y * 0.5f + 0.5f);

            return point;
        }

@bgolus Do you have any idea why this might be happening? You seem to know a lot about stereo rendering, so it would be greatly appreciated if you have any idea what’s going on. My right eye projection matrix in Unity is incorrect while my left eye projection matrix is correct.