예제 #1
0
        private void UpdateProfile()
        {
            GetProfile(profileData);
            GvrProfile.Viewer device = new GvrProfile.Viewer();
            GvrProfile.Screen screen = new GvrProfile.Screen();
            device.maxFOV.outer          = profileData[0];
            device.maxFOV.upper          = profileData[1];
            device.maxFOV.inner          = profileData[2];
            device.maxFOV.lower          = profileData[3];
            screen.width                 = profileData[4];
            screen.height                = profileData[5];
            screen.border                = profileData[6];
            device.lenses.separation     = profileData[7];
            device.lenses.offset         = profileData[8];
            device.lenses.screenDistance = profileData[9];
            device.lenses.alignment      = (int)profileData[10];
            device.distortion.Coef       = new [] { profileData[11], profileData[12] };
            Profile.screen               = screen;
            Profile.viewer               = device;

            float[] rect = new float[4];
            Profile.GetLeftEyeNoLensTanAngles(rect);
            float maxRadius = GvrProfile.GetMaxRadius(rect);

            Profile.viewer.inverse = GvrProfile.ApproximateInverse(
                Profile.viewer.distortion, maxRadius);
        }
예제 #2
0
 private void SetShaderGlobals()
 {
     // For any shaders that want to use these numbers for distortion correction.  But only
     // if distortion correction is needed, yet not already being handled by another method.
     if (GvrViewer.Instance.VRModeEnabled &&
         GvrViewer.Instance.DistortionCorrection == GvrViewer.DistortionCorrectionMethod.None)
     {
         GvrProfile p = GvrViewer.Instance.Profile;
         // Distortion vertex shader currently setup for only 6 coefficients.
         if (p.viewer.inverse.Coef.Length > 6)
         {
             Debug.LogWarning("Inverse distortion correction has more than 6 coefficents. "
                              + "Shader only supports 6.");
         }
         Matrix4x4 mat = new Matrix4x4()
         {
         };
         for (int i = 0; i < p.viewer.inverse.Coef.Length; i++)
         {
             mat[i] = p.viewer.inverse.Coef[i];
         }
         Shader.SetGlobalMatrix("_Undistortion", mat);
         float[] rect = new float[4];
         p.GetLeftEyeVisibleTanAngles(rect);
         float r = GvrProfile.GetMaxRadius(rect);
         Shader.SetGlobalFloat("_MaxRadSq", r * r);
     }
 }