Beispiel #1
0
        /// <summary>
        /// Starts this instance.
        /// </summary>
        private void Start()
        {
            if (this.OnConfigureVrModeParms != null)
            {
                this.OnConfigureVrModeParms();
            }
#if UNITY_ANDROID && !UNITY_EDITOR
            if (VrManager.Instance.TimeWarp)
            {
                MiHMD.EyeParameter leftEyeDesc = this.Hmd.GetEyeParameter(Eyes.Left);
                Vector2            resolution  = leftEyeDesc.Resolution;
                SetEyeParms((int)resolution.x, (int)resolution.y);

                this.InitRenderThread();

                EnableChromaticAberration(this.ChromaticCorrection);
            }
#endif
        }
Beispiel #2
0
        /// <summary>
        /// Configures the camera.
        /// </summary>
        /// <param name="eye">The eye.</param>
        /// <returns>the camera relate to the eye</returns>
        private Camera ConfigureCamera(Eyes eye)
        {
            if (eye == Eyes.Center)
            {
                Camera centerEye = this.CenterEyeTransform.GetComponent <Camera>();

                // Clearing nothing to make sure the output image is not affected by this camera
                this.CenterEyeCamera.clearFlags = CameraClearFlags.Nothing;

                return(centerEye);
            }

            Transform anchor = eye == Eyes.Left ? this.LeftEyeTransform : this.RightEyeTransform;
            Camera    cam    = anchor.GetComponent <Camera>();

#if UNITY_ANDROID && !UNITY_EDITOR
            if (VrManager.Instance.TimeWarp)
            {
                MiHMD.EyeParameter eyeDesc = VrManager.Instance.Hmd.GetEyeParameter(eye);

                cam.fieldOfView = eyeDesc.Fov.y;
                cam.aspect      = eyeDesc.Resolution.x / eyeDesc.Resolution.y;
                cam.rect        = new Rect(0f, 0f, 1.0f, 1.0f);
                cam.hdr         = VrManager.Instance.IsHdrEnabled;
#if UNITY_5_6
                // current version is 5.6.*, not use shared depth buffer!
                cam.targetTexture = VrManager.Instance.Hmd.GetEyeSceneTexture(eye);
#else
                // current version is not 5.6.*, use shared depth buffer for each eye!
                cam.SetTargetBuffers(VrManager.Instance.Hmd.GetEyeSceneTexture(eye).colorBuffer,
                                     VrManager.Instance.Hmd.GetEyeSceneTextureDepthBuffer(eye));
#endif

                // Enforce camera render order
                cam.depth = (eye == Eyes.Left) ?
                            (int)PluginEvents.LeftEyeEndFrame :
                            (int)PluginEvents.RightEyeEndFrame;

                // AA is documented to have no effect in deferred, but it causes black screens.
                if (cam.actualRenderingPath == RenderingPath.DeferredLighting)
                {
                    QualitySettings.antiAliasing = 0;
                }
            }
#endif
            if (!VrManager.Instance.TimeWarp)
            {
                cam.fieldOfView = 97.5f;
                if (eye == Eyes.Left)
                {
                    cam.rect = new Rect(0.0f, 0.0f, 0.5f, 1.0f);
                }
                else
                {
                    cam.rect = new Rect(0.5f, 0.0f, 0.5f, 1.0f);
                }

                cam.targetTexture = MiEmulation.Instance.StereoRT;
                cam.hdr           = VrManager.Instance.IsHdrEnabled;
                cam.depth         = 0;
                if (cam.actualRenderingPath == RenderingPath.DeferredLighting ||
                    cam.actualRenderingPath == RenderingPath.DeferredShading)
                {
                    QualitySettings.antiAliasing = 0;
                }

                cam.enabled = true;
            }

            return(cam);
        }