Ceto.UnderWater.RenderOceanDepth(DepthData, UnityEngine.RenderTexture, UnityEngine.Vector3, UnityEngine.Quaternion, UnityEngine.Matrix4x4)

Here are the examples of the csharp api Ceto.UnderWater.RenderOceanDepth(DepthData, UnityEngine.RenderTexture, UnityEngine.Vector3, UnityEngine.Quaternion, UnityEngine.Matrix4x4) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

19 View Source File : UnderWater.cs
License : MIT License
Project Creator : Scrawk

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

        }

19 View Source File : UnderWater.cs
License : MIT License
Project Creator : Scrawk

public void RenderOceanDepth(GameObject go)
        {

			try
			{

                if (!enabled) return;

                Camera cam = Camera.current;
                if (cam == null) return;

                CameraData data = m_ocean.FindCameraData(cam);

                if (data.depth == null)
                    data.depth = new DepthData();

                if (data.depth.IsViewUpdated(cam)) return;

                //If this camera has disable the underwater turn it off in the shader and return.
                if (GetDisableUnderwater(data.settings))
                {
                    Shader.DisableKeyword("CETO_UNDERWATER_ON");
                    data.depth.SetViewAsUpdated(cam);
                    return;
                }
                else
                {
                    Shader.EnableKeyword("CETO_UNDERWATER_ON");
                }
                
                if (/*cam.name == "SceneCamera" ||*/ SystemInfo.graphicsShaderLevel < 30)
                {
                    //These texture will not be generated so zero to some that will not cause a issue if sampled.
                    Shader.SetGlobalTexture(Ocean.OCEAN_DEPTH_TEXTURE_NAME0, Texture2D.whiteTexture);
                    Shader.SetGlobalTexture(Ocean.OCEAN_DEPTH_TEXTURE_NAME1, Texture2D.whiteTexture);
                    Shader.SetGlobalTexture(Ocean.DEPTH_GRAB_TEXTURE_NAME, Texture2D.whiteTexture);
                    Shader.SetGlobalTexture(Ocean.NORMAL_FADE_TEXTURE_NAME, Texture2D.blackTexture);

                    //If not using the ocean depths all thats needed is the IVP
                    //to extract the world pos from the depth buffer.
                    BindIVPMatrix(cam.projectionMatrix, cam.worldToCameraMatrix);

                    data.depth.SetViewAsUpdated(cam);
                }
                else if (depthMode == DEPTH_MODE.USE_DEPTH_BUFFER)
                {
                    //These texture will not be generated so zero to some that will not cause a issue if sampled.
                    Shader.SetGlobalTexture(Ocean.OCEAN_DEPTH_TEXTURE_NAME0, Texture2D.whiteTexture);
                    Shader.SetGlobalTexture(Ocean.OCEAN_DEPTH_TEXTURE_NAME1, Texture2D.whiteTexture);

                    //Cam must have depth mode enabled to use depth buffer.
                    cam.depthTextureMode |= DepthTextureMode.Depth;
                    cam.depthTextureMode |= DepthTextureMode.DepthNormals;

                    CreateRefractionCommand(cam, data.depth);

                    //If not using the ocean depths all thats needed is the IVP
                    //to extract the world pos from the depth buffer.
                    BindIVPMatrix(cam.projectionMatrix, cam.worldToCameraMatrix);

                    data.depth.SetViewAsUpdated(cam);
                }
                else if (depthMode == DEPTH_MODE.USE_OCEAN_DEPTH_Preplaced)
                {
                    //These texture will not be generated so zero to some that will not cause a issue if sampled.
                    Shader.SetGlobalTexture(Ocean.DEPTH_GRAB_TEXTURE_NAME, Texture2D.whiteTexture);
                    Shader.SetGlobalTexture(Ocean.NORMAL_FADE_TEXTURE_NAME, Texture2D.blackTexture);

                    CreateDepthCameraFor(cam, data.depth);
                    CreateRefractionCommand(cam, data.depth);

                    data.depth.cam.cullingMask = GetOceanDepthsLayermask(data.settings);
                    data.depth.cam.cullingMask = OceanUtility.HideLayer(data.depth.cam.cullingMask, Ocean.OCEAN_LAYER);

                    if (cam.stereoEnabled)
                        RenderSteroOceanDepth(data.depth, cam);
                    else
                    {
                        Shader.DisableKeyword("CETO_STERO_CAMERA");
                        RenderOceanDepth(data.depth, data.depth.target0, cam.transform.position, cam.transform.rotation, cam.projectionMatrix);
                        Shader.SetGlobalTexture(Ocean.OCEAN_DEPTH_TEXTURE_NAME0, data.depth.target0);
                    }
                    
                    data.depth.SetViewAsUpdated(cam);
                }

			}
			catch(Exception e)
			{
				Ocean.LogError(e.ToString());
				WasError = true;
				enabled = false;
			}
        }