public override void Render(ZView zView, IntPtr connection, IntPtr receivedFrame)
        {
            // Cache whether transparency is enabled.
            _isTransparencyEnabled = zView.ARModeEnableTransparency;

            // Grab the viewer scale.
            float viewerScale = CoreCamera.transform.lossyScale.x;


            ///////////////////////////////
            // Camera Properties Update
            ///////////////////////////////

            // Cache the camera's culling mask and near/far clip planes so that they
            // can be restored after it renders the frame.
            int   originalCullingMask   = _compositorCamera.cullingMask;
            float originalNearClipPlane = _compositorCamera.nearClipPlane;
            float originalFarClipPlane  = _compositorCamera.farClipPlane;

            // Grab the web cam's display space pose matrix and intrinsic values
            // from the frame data.
            Matrix4x4 cameraPoseMatrixInDisplaySpace = zView.GetFrameDataMatrix4x4(receivedFrame, ZView.FrameDataKey.CameraPose);
            float     focalLength           = zView.GetFrameDataFloat(receivedFrame, ZView.FrameDataKey.CameraFocalLength);
            float     principalPointOffsetX = zView.GetFrameDataFloat(receivedFrame, ZView.FrameDataKey.CameraPrincipalPointOffsetX);
            float     principalPointOffsetY = zView.GetFrameDataFloat(receivedFrame, ZView.FrameDataKey.CameraPrincipalPointOffsetY);
            float     pixelAspectRatio      = zView.GetFrameDataFloat(receivedFrame, ZView.FrameDataKey.CameraPixelAspectRatio);
            float     axisSkew = zView.GetFrameDataFloat(receivedFrame, ZView.FrameDataKey.CameraAxisSkew);

            // Update the near and far clip values to account for viewer scale.
            float nearClipPlane = originalNearClipPlane * viewerScale;
            float farClipPlane  = originalFarClipPlane * viewerScale;

            // Calculate the camera's transform by transforming its corresponding
            // display space pose matrix to world space.
            Matrix4x4 displayToWorld =
                CoreCamera.transform.parent?.localToWorldMatrix ??
                Matrix4x4.identity;

            Matrix4x4 worldPoseMatrix = displayToWorld * cameraPoseMatrixInDisplaySpace;

            // Calculate the camera's projection matrix based on the camera intrinsic
            // and near/far clip values.
            Matrix4x4 projectionMatrix =
                this.ComputeProjectionMatrix(
                    focalLength,
                    principalPointOffsetX,
                    principalPointOffsetY,
                    pixelAspectRatio,
                    axisSkew,
                    (float)_imageWidth,
                    (float)_imageHeight,
                    nearClipPlane,
                    farClipPlane);

            // Update the primary camera's properties (i.e. transform, projection, etc.).
            _compositorCamera.transform.position = worldPoseMatrix.GetColumn(3);
            _compositorCamera.transform.rotation = Quaternion.LookRotation(worldPoseMatrix.GetColumn(2), worldPoseMatrix.GetColumn(1));
            _compositorCamera.projectionMatrix   = projectionMatrix;
            _compositorCamera.cullingMask        = _compositorCamera.cullingMask & ~(zView.ARModeIgnoreLayers);
            _compositorCamera.nearClipPlane      = nearClipPlane;
            _compositorCamera.farClipPlane       = farClipPlane;

            // Copy the compositor camera's properties to the secondary camera.
            _secondaryCamera.CopyFrom(_compositorCamera);

#if UNITY_5_6_OR_NEWER
            //make sure this is not HDR, it's not supported
            _secondaryCamera.allowHDR = false;
#endif // UNITY_5_6_OR_NEWER


            ///////////////////////////////
            // Box Mask Update
            ///////////////////////////////

            // Enable the box mask to be rendered by the depth camera.
            // Note: The box mask will be disabled immediately after it is rendered
            //       by the AR depth camera so that it isn't inadvertently rendered by
            //       other cameras in the scene.
            _boxMaskObject.SetActive(true);

            // Update the box mask's transform and layer.
            _boxMaskObject.transform.SetPositionAndRotation(
                CoreCamera.transform.parent?.position ?? Vector3.zero,
                CoreCamera.transform.parent?.rotation ?? Quaternion.identity);
            _boxMaskObject.transform.localScale = CoreCamera.transform.lossyScale;
            _boxMaskObject.layer = zView.ARModeMaskLayer;

            // Update the box mask's size.
            _boxMask.SetSize(zView.ARModeMaskSize);

            // Set the box mask's cutout size to be the size of the viewport
            // in viewport space (meters) since its associated transform's
            // local scale accounts for viewer scale.
            _boxMask.SetCutoutSize(ZProviderProxy.Instance.DisplaySize);

            // Update the box mask's render queue priority.
            _boxMask.SetRenderQueue(zView.ARModeMaskRenderQueue);


            ///////////////////////////////
            // Scene Render
            ///////////////////////////////

            if (zView.ARModeEnableTransparency)
            {
                this.RenderRGBA(zView);
            }
            else
            {
                this.RenderRGB(zView);
            }


            // Disable the box mask so that it isn't inadvertently rendered by
            // any other cameras in the scene.
            _boxMaskObject.SetActive(false);

            // Restore the camera's culling mask and near/far clip planes.
            _compositorCamera.cullingMask   = originalCullingMask;
            _compositorCamera.nearClipPlane = originalNearClipPlane;
            _compositorCamera.farClipPlane  = originalFarClipPlane;
        }