Beispiel #1
0
    // Start
    new void Start()
    {
        base.Start();

        // Get the OVRCameraController
        CameraController = gameObject.transform.parent.GetComponent <OVRCameraController>();

        if (CameraController == null)
        {
            Debug.LogWarning("WARNING: OVRCameraController not found!");
        }

        // NOTE: MSAA TEXTURES NOT AVAILABLE YET
        // Set CameraTextureScale (increases the size of the texture we are rendering into
        // for a better pixel match when post processing the image through lens distortion)
#if MSAA_ENABLED
        CameraTextureScale = OVRDeviceImposter.DistortionScale();
#endif
        // If CameraTextureScale is not 1.0f, create a new texture and assign to target texture
        // Otherwise, fall back to normal camera rendering
        if ((CameraTexture == null) && (CameraTextureScale > 1.0f))
        {
            int w = (int)(Screen.width / 2.0f * CameraTextureScale);
            int h = (int)(Screen.height * CameraTextureScale);
            CameraTexture = new RenderTexture(w, h, 24);               // 24 bit colorspace

            // NOTE: MSAA TEXTURES NOT AVAILABLE YET
            // This value should be the default for MSAA textures
            // CameraTexture.antiAliasing = 4;
            // Set it within the project
#if MSAA_ENABLED
            CameraTexture.antiAliasing = QualitySettings.antiAliasing;
#endif
        }
    }
Beispiel #2
0
    // SetCameraLensCorrection
    void ConfigureCameraLensCorrection(ref Camera camera)
    {
        // Get the distortion scale and aspect ratio to use when calculating distortion shader
        float distortionScale = 1.0f / OVRDeviceImposter.DistortionScale();
        float aspectRatio     = OVRDeviceImposter.CalculateAspectRatio();

        // These values are different in the SDK World Demo; Unity renders each camera to a buffer
        // that is normalized, so we will respect this rule when calculating the distortion inputs
        float NormalizedWidth  = 1.0f;
        float NormalizedHeight = 1.0f;

        OVRLensCorrection lc = camera.GetComponent <OVRLensCorrection>();

        lc._Scale.x        = (NormalizedWidth / 2.0f) * distortionScale;
        lc._Scale.y        = (NormalizedHeight / 2.0f) * distortionScale * aspectRatio;
        lc._ScaleIn.x      = (2.0f / NormalizedWidth);
        lc._ScaleIn.y      = (2.0f / NormalizedHeight) / aspectRatio;
        lc._HmdWarpParam.x = DistK0;
        lc._HmdWarpParam.y = DistK1;
        lc._HmdWarpParam.z = DistK2;
    }