Ceto.UnderWater.RenderOceanMask(MaskData, UnityEngine.RenderTexture, UnityEngine.Vector3, UnityEngine.Quaternion, UnityEngine.Matrix4x4, UnityEngine.Shader)

Here are the examples of the csharp api Ceto.UnderWater.RenderOceanMask(MaskData, UnityEngine.RenderTexture, UnityEngine.Vector3, UnityEngine.Quaternion, UnityEngine.Matrix4x4, UnityEngine.Shader) 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

public void RenderOceanMask(GameObject go)
        {

			try
			{

	            if (!enabled) return;

	            if (oceanMaskSdr == null) return;

	            if (underwaterMode == UNDERWATER_MODE.ABOVE_ONLY) return;

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

                CameraData data = m_ocean.FindCameraData(cam);

                if (data.mask == null)
	                data.mask = new MaskData();

	            if (data.mask.IsViewUpdated(cam)) return;
                
                if (cam.name == "SceneCamera" || cam.GetComponent<UnderWaterPostEffect>() == null || SystemInfo.graphicsShaderLevel < 30 || GetDisableUnderwater(data.settings))
                {
                    //Scene camera should never need the mask so just bind something that wont cause a issue.
                    //If the camera is not using a post effect there is no need for the mask to be rendered.

                    Shader.SetGlobalTexture(Ocean.OCEAN_MASK_TEXTURE_NAME0, Texture2D.blackTexture);
                    Shader.SetGlobalTexture(Ocean.OCEAN_MASK_TEXTURE_NAME1, Texture2D.blackTexture);
                    data.mask.SetViewAsUpdated(cam);
                }
                else
                {

                    CreateMaskCameraFor(cam, data.mask);

                    FitBottomToCamera();

                    Shader sdr = (m_ocean.Projection.IsFlipped) ? oceanMaskFlippedSdr : oceanMaskSdr;

                    if (cam.stereoEnabled)
                        RenderSteroOceanMask(data.mask, cam, sdr);
                    else
                    {
                        Shader.DisableKeyword("CETO_STERO_CAMERA");
                        RenderOceanMask(data.mask, data.mask.target0, cam.transform.position, cam.transform.rotation, cam.projectionMatrix, sdr);
                        Shader.SetGlobalTexture(Ocean.OCEAN_MASK_TEXTURE_NAME0, data.mask.target0);
                    }

                    data.mask.SetViewAsUpdated(cam);
                }

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

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

void RenderSteroOceanMask(MaskData data, Camera cam, Shader sdr)
        {
#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);
                    RenderOceanMask(data, data.target0, eyePos, eyeRot, projection, sdr);
                    Shader.SetGlobalTexture(Ocean.OCEAN_MASK_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);
                    RenderOceanMask(data, data.target1, eyePos, eyeRot, projection, sdr);
                    Shader.SetGlobalTexture(Ocean.OCEAN_MASK_TEXTURE_NAME1, data.target1);
                }
            }
            else
            {
                Shader.DisableKeyword("CETO_STERO_CAMERA");
                RenderOceanMask(data, data.target0, cam.transform.position, cam.transform.rotation, cam.projectionMatrix, sdr);
                Shader.SetGlobalTexture(Ocean.OCEAN_MASK_TEXTURE_NAME0, data.target0);
            }
#else
            Shader.DisableKeyword("CETO_STERO_CAMERA");
            RenderOceanMask(data, data.target0, cam.transform.position, cam.transform.rotation, cam.projectionMatrix, sdr);
            Shader.SetGlobalTexture(Ocean.OCEAN_MASK_TEXTURE_NAME0, data.target0);
#endif
        }