Beispiel #1
0
        /// <summary>
        /// Render stero reflections for VR.
        /// </summary>
        void RenderSteroReflection(ReflectionData data, Camera cam, OceanCameraSettings settings)
        {
#if UNITY_540_OR_HIGHER && CETO_USE_STEAM_VR
            if (OceanVR.OpenVRInUse)
            {
                Shader.EnableKeyword("CETO_STERO_CAMERA");
                if (cam.stereoTargetEye == StereoTargetEyeMask.Both || cam.stereoTargetEye == StereoTargetEyeMask.Left)
                {
                    Vector3 eyePos; Quaternion eyeRot; Matrix4x4 projection;
                    OceanVR.GetSteamVRLeftEye(cam, out eyePos, out eyeRot, out projection);
                    RenderReflection(data.cam, data.target0, eyePos, eyeRot, projection, settings);
                }

                if (cam.stereoTargetEye == StereoTargetEyeMask.Both || cam.stereoTargetEye == StereoTargetEyeMask.Right)
                {
                    Vector3 eyePos; Quaternion eyeRot; Matrix4x4 projection;
                    OceanVR.GetSteamVRRightEye(cam, out eyePos, out eyeRot, out projection);
                    RenderReflection(data.cam, data.target1, eyePos, eyeRot, projection, settings);
                }
            }
            else
            {
                Shader.DisableKeyword("CETO_STERO_CAMERA");
                RenderReflection(data.cam, data.target0, cam.transform.position, cam.transform.rotation, cam.projectionMatrix, settings);
            }
#else
            Shader.DisableKeyword("CETO_STERO_CAMERA");
            RenderReflection(data.cam, data.target0, cam.transform.position, cam.transform.rotation, cam.projectionMatrix, settings);
#endif
        }
Beispiel #2
0
        /// <summary>
        /// Render stero depth pass for VR.
        /// The depths need to be rendered twice (once for each eye).
        /// </summary>
        void RenderSteroOceanDepth(DepthData data, Camera cam)
        {
#if UNITY_540_OR_HIGHER && CETO_USE_STEAM_VR
            if (OceanVR.OpenVRInUse)
            {
                Shader.EnableKeyword("CETO_STERO_CAMERA");
                if (cam.stereoTargetEye == StereoTargetEyeMask.Both || cam.stereoTargetEye == StereoTargetEyeMask.Left)
                {
                    Vector3 eyePos; Quaternion eyeRot; Matrix4x4 projection;
                    OceanVR.GetSteamVRLeftEye(cam, out eyePos, out eyeRot, out projection);
                    RenderOceanDepth(data, data.target0, eyePos, eyeRot, projection);
                    Shader.SetGlobalTexture(Ocean.OCEAN_DEPTH_TEXTURE_NAME0, data.target0);
                }

                if (cam.stereoTargetEye == StereoTargetEyeMask.Both || cam.stereoTargetEye == StereoTargetEyeMask.Right)
                {
                    Vector3 eyePos; Quaternion eyeRot; Matrix4x4 projection;
                    OceanVR.GetSteamVRRightEye(cam, out eyePos, out eyeRot, out projection);
                    RenderOceanDepth(data, data.target1, eyePos, eyeRot, projection);
                    Shader.SetGlobalTexture(Ocean.OCEAN_DEPTH_TEXTURE_NAME1, data.target1);
                }
            }
            else
            {
                Shader.DisableKeyword("CETO_STERO_CAMERA");
                RenderOceanDepth(data, data.target0, cam.transform.position, cam.transform.rotation, cam.projectionMatrix);
                Shader.SetGlobalTexture(Ocean.OCEAN_DEPTH_TEXTURE_NAME0, data.target0);
            }
#else
            Shader.DisableKeyword("CETO_STERO_CAMERA");
            RenderOceanDepth(data, data.target0, cam.transform.position, cam.transform.rotation, cam.projectionMatrix);
            Shader.SetGlobalTexture(Ocean.OCEAN_DEPTH_TEXTURE_NAME0, data.target0);
#endif
        }