Specifies the size and field-of-view for one eye texture.
Exemple #1
0
    /// <summary>
    /// Updates resolution of eye texture
    /// </summary>
    void UpdateResolutionEyeTexture()
    {
#if UNITY_2017_2_OR_NEWER
        OVRDisplay.EyeRenderDesc leftEyeDesc  = OVRManager.display.GetEyeRenderDesc(UnityEngine.XR.XRNode.LeftEye);
        OVRDisplay.EyeRenderDesc rightEyeDesc = OVRManager.display.GetEyeRenderDesc(UnityEngine.XR.XRNode.RightEye);

        float scale = UnityEngine.XR.XRSettings.renderViewportScale;
#else
        OVRDisplay.EyeRenderDesc leftEyeDesc  = OVRManager.display.GetEyeRenderDesc(UnityEngine.VR.VRNode.LeftEye);
        OVRDisplay.EyeRenderDesc rightEyeDesc = OVRManager.display.GetEyeRenderDesc(UnityEngine.VR.VRNode.RightEye);

        float scale = UnityEngine.VR.VRSettings.renderViewportScale;
#endif
        float w = (int)(scale * (float)(leftEyeDesc.resolution.x + rightEyeDesc.resolution.x));
        float h = (int)(scale * (float)Mathf.Max(leftEyeDesc.resolution.y, rightEyeDesc.resolution.y));

        strResolutionEyeTexture = System.String.Format("Resolution : {0} x {1}", w, h);
    }
    private void Start()
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        // Configure app-specific vr mode parms such as clock frequencies
        if (OnConfigureVrModeParms != null)
        {
            OnConfigureVrModeParms();
        }

        // NOTE: For Android, the resolution should be the same for both left and right eye
        OVRDisplay.EyeRenderDesc leftEyeDesc = OVRManager.display.GetEyeRenderDesc(OVREye.Left);
        Vector2 resolution = leftEyeDesc.resolution;
        OVR_SetEyeParms((int)resolution.x, (int)resolution.y);

        // This will trigger the init on the render thread
        InitRenderThread();
#endif
    }
Exemple #3
0
    private Camera ConfigureCamera(OVREye eye)
    {
        Transform anchor = (eye == OVREye.Left) ? leftEyeAnchor : rightEyeAnchor;
        Camera    cam    = anchor.GetComponent <Camera>();

        OVRDisplay.EyeRenderDesc eyeDesc = OVRManager.display.GetEyeRenderDesc(eye);

        cam.fieldOfView   = eyeDesc.fov.y;
        cam.aspect        = eyeDesc.resolution.x / eyeDesc.resolution.y;
        cam.rect          = new Rect(0f, 0f, OVRManager.instance.virtualTextureScale, OVRManager.instance.virtualTextureScale);
        cam.targetTexture = OVRManager.display.GetEyeTexture(eye);

#if !UNITY_ANDROID || UNITY_EDITOR
#if OVR_USE_PROJ_MATRIX
        cam.projectionMatrix = OVRManager.display.GetProjection((int)eye, cam.nearClipPlane, cam.farClipPlane);
#endif
#endif

        return(cam);
    }
 /// <summary>
 /// Updates the FOV.
 /// </summary>
 void UpdateFOV()
 {
     OVRDisplay.EyeRenderDesc eyeDesc = OVRManager.display.GetEyeRenderDesc(UnityEngine.XR.XRNode.LeftEye);
     strFOV = System.String.Format("FOV (deg): {0:F3}", eyeDesc.fov.y);
 }
 /// <summary>
 /// Updates the FOV.
 /// </summary>
 void UpdateFOV()
 {
     OVRDisplay.EyeRenderDesc eyeDesc = OVRManager.display.GetEyeRenderDesc(OVREye.Left);
     strFOV = System.String.Format("FOV (deg): {0:F3}", eyeDesc.fov.y);
 }