Ejemplo n.º 1
0
        public SrdXrResult GetCurrentProjMatrices(float nearClip, float farClip, out EyeProjectionMatrices projMatrices)
        {
            projMatrices = (_prevProjMatrix != null) ? _prevProjMatrix : SRDFaceTracker.CreateDefaultProjMatrices();

            var leftMatrix  = projMatrices.LeftMatrix;
            var rightMatrix = projMatrices.RightMatrix;
            var xrResult    = SRDCorePlugin.GetProjectionMatrix(SRDSessionHandler.SessionHandle, nearClip, farClip,
                                                                out leftMatrix, out rightMatrix);

            projMatrices = new EyeProjectionMatrices(leftMatrix, rightMatrix);
            if (xrResult == SrdXrResult.ERROR_HANDLE_INVALID || xrResult == SrdXrResult.ERROR_SESSION_NOT_RUNNING)
            {
                projMatrices = SRDFaceTracker.CreateDefaultProjMatrices();
            }
            _prevProjMatrix = projMatrices;
            return(xrResult);
        }
        public SRDEyeViewRenderer()
        {
            _eyeTransform = new Dictionary <EyeType, Transform>();
            _eyeCamera    = new Dictionary <EyeType, Camera>();
            //_eyeCamRenderTexture = new Dictionary<EyeType, RenderTexture>();
            _eyeCamRenderTextureCache = new Dictionary <EyeType, RenderTexture>();
            _eyeCamMaterial           = new Dictionary <EyeType, Material>();

            _eyeTypes = new List <EyeType>()
            {
                EyeType.Left, EyeType.Right
            };
            _isSRPUsed = (GraphicsSettings.renderPipelineAsset != null);

            _currentFacePose     = SRDFaceTracker.CreateDefaultFacePose();
            _currentProjMatrices = SRDFaceTracker.CreateDefaultProjMatrices();

            var width  = SRDSettings.DeviceInfo.ScreenRect.Width;
            var height = SRDSettings.DeviceInfo.ScreenRect.Height;

            foreach (var type in _eyeTypes)
            {
                // RenderTarget
                //var outrt = new RenderTexture(width, height, RenderTextureDepth, RenderTextureFormat.ARGB32);
                //outrt.name = SRDHelper.SRDConstants.EyeCamRenderTexDefaultName + SRDHelper.EyeSideName[type] + "_Temp";
                //outrt.Create();
                //_eyeCamRenderTexture.Add(type, outrt);
                var camrt = new RenderTexture(width, height, RenderTextureDepth, RenderTextureFormat.ARGB32,
                                              (QualitySettings.desiredColorSpace == ColorSpace.Linear) ? RenderTextureReadWrite.Linear : RenderTextureReadWrite.Default);
                camrt.name = SRDHelper.SRDConstants.EyeCamRenderTexDefaultName + SRDHelper.EyeSideName[type];
                camrt.Create();
                _eyeCamRenderTextureCache.Add(type, camrt);

                var homographyMaterial = new Material(Shader.Find("uHomography/Homography"));
                homographyMaterial.hideFlags = HideFlags.HideAndDontSave;
                _eyeCamMaterial[type]        = homographyMaterial;
            }
        }