Example #1
0
    /// <summary>
    /// Set the rendering settings (rendering path, shaders values) for camera Left and right
    /// Activate/Deactivate depth occlusions, Change rendering path...
    /// </summary>
    void setRenderingSettings()
    {
        ZEDRenderingPlane textureLeftOverlay = GetLeftCameraTransform().GetComponent <ZEDRenderingPlane>();

        textureLeftOverlay.SetPostProcess(postProcessing);
        GetLeftCameraTransform().GetComponent <Camera>().renderingPath = RenderingPath.UsePlayerSettings;
        Shader.SetGlobalFloat("_ZEDFactorAffectReal", m_cameraBrightness);

        ZEDRenderingPlane textureRightOverlay = null;

        if (IsStereoRig)
        {
            textureRightOverlay = GetRightCameraTransform().GetComponent <ZEDRenderingPlane>();
            textureRightOverlay.SetPostProcess(postProcessing);
        }

        ZEDRenderingMode renderingPath = (ZEDRenderingMode)GetLeftCameraTransform().GetComponent <Camera>().actualRenderingPath;

        //Check that we are in forward or deffered
        if (renderingPath != ZEDRenderingMode.FORWARD && renderingPath != ZEDRenderingMode.DEFERRED)
        {
            Debug.LogError("[ZED Plugin] Only Forward and Deferred Shading rendering path are supported");
            GetLeftCameraTransform().GetComponent <Camera> ().renderingPath = RenderingPath.Forward;
            if (IsStereoRig)
            {
                GetRightCameraTransform().GetComponent <Camera> ().renderingPath = RenderingPath.Forward;
            }
        }

        //Set Depth Occ
        if (renderingPath == ZEDRenderingMode.FORWARD)
        {
            textureLeftOverlay.ManageKeyWordPipe(!depthOcclusion, "NO_DEPTH_OCC");
            if (textureRightOverlay)
            {
                textureRightOverlay.ManageKeyWordPipe(!depthOcclusion, "NO_DEPTH_OCC");
            }
        }
        else if (renderingPath == ZEDRenderingMode.DEFERRED)
        {
            textureLeftOverlay.ManageKeyWordDefferedMat(!depthOcclusion, "NO_DEPTH_OCC");
            if (textureRightOverlay)
            {
                textureRightOverlay.ManageKeyWordDefferedMat(!depthOcclusion, "NO_DEPTH_OCC");
            }
        }
    }
Example #2
0
    void OnValidate()
    {
        if (zedCamera != null)
        {
            if (!isTrackingEnable && enableTracking)
            {
                //Enables the tracking and initializes the first position of the camera
                Quaternion quat = Quaternion.identity;
                Vector3    vec  = new Vector3(0, 0, 0);
                enablePoseSmoothing = enableSpatialMemory;
                if (!(enableTracking = (zedCamera.EnableTracking(ref quat, ref vec, enableSpatialMemory, enablePoseSmoothing, pathSpatialMemory) == sl.ERROR_CODE.SUCCESS)))
                {
                    isZEDTracked = false;
                    throw new Exception(ZEDLogMessage.Error2Str(ZEDLogMessage.ERROR.TRACKING_NOT_INITIALIZED));
                }
                else
                {
                    isZEDTracked     = true;
                    isTrackingEnable = true;
                }
            }


            if (isTrackingEnable && !enableTracking)
            {
                isZEDTracked = false;
                lock (grabLock) {
                    zedCamera.DisableTracking();
                }
                isTrackingEnable = false;
            }


            //Create ZEDTextureOverlay object to handle left images
            ZEDRenderingPlane textureLeftOverlay = GetLeftCameraTransform().GetComponent <ZEDRenderingPlane>();
            textureLeftOverlay.SetPostProcess(postProcessing);
            Shader.SetGlobalFloat("_ZEDFactorAffectReal", cameraBrightness);


            //Create ZEDTextureOverlay object to handle Right images if a right camera is present
            if (IsStereoRig)
            {
                ZEDRenderingPlane textureRightOverlay = GetRightCameraTransform().GetComponent <ZEDRenderingPlane>();
                textureRightOverlay.SetPostProcess(postProcessing);
            }

            if (renderingPath == ZEDRenderingMode.FORWARD)
            {
                if (depthOcclusion)
                {
                    textureLeftOverlay.ManageKeyWordPipe(false, "NO_DEPTH_OCC");
                    if (IsStereoRig)
                    {
                        textureLeftOverlay.ManageKeyWordPipe(false, "NO_DEPTH_OCC");
                    }
                }
                else
                {
                    textureLeftOverlay.ManageKeyWordPipe(true, "NO_DEPTH_OCC");
                    if (IsStereoRig)
                    {
                        textureLeftOverlay.ManageKeyWordPipe(true, "NO_DEPTH_OCC");
                    }
                }
            }
            else if (renderingPath == ZEDRenderingMode.DEFERRED)
            {
                if (depthOcclusion)
                {
                    textureLeftOverlay.ManageKeyWordDefferedMat(false, "NO_DEPTH_OCC");
                    if (IsStereoRig)
                    {
                        textureLeftOverlay.ManageKeyWordDefferedMat(false, "NO_DEPTH_OCC");
                    }
                }
                else
                {
                    textureLeftOverlay.ManageKeyWordDefferedMat(true, "NO_DEPTH_OCC");
                    if (IsStereoRig)
                    {
                        textureLeftOverlay.ManageKeyWordDefferedMat(true, "NO_DEPTH_OCC");
                    }
                }
            }
        }
    }