Ceto.PlanarReflection.RenderReflection(UnityEngine.Camera, UnityEngine.RenderTexture, UnityEngine.Vector3, UnityEngine.Quaternion, UnityEngine.Matrix4x4, OceanCameraSettings)

Here are the examples of the csharp api Ceto.PlanarReflection.RenderReflection(UnityEngine.Camera, UnityEngine.RenderTexture, UnityEngine.Vector3, UnityEngine.Quaternion, UnityEngine.Matrix4x4, OceanCameraSettings) 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 : PlanarReflection.cs
License : MIT License
Project Creator : Scrawk

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

        }

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

public void RenderReflection(GameObject go)
		{

            try
            {

                if (!enabled) return;

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

                CameraData data = m_ocean.FindCameraData(cam);

                //Create the data needed if not already created.
                if (data.reflection == null)
				{
                    data.reflection = new ReflectionData();
                }

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

				//If this camera has disable the reflection turn it off in the shader and return.
				if(GetDisableReflections(data.settings))
				{
					Shader.DisableKeyword("CETO_REFLECTION_ON");
                    data.reflection.SetViewAsUpdated(cam);
                    return;
				}
				else
				{
					Shader.EnableKeyword("CETO_REFLECTION_ON");
				}

                RenderTexture reflections0 = null;
                RenderTexture reflections1 = null;

                if (data.reflection.cam != null)
                {
                    DisableFog disableFog = data.reflection.cam.GetComponent<DisableFog>();
                    if(disableFog != null) disableFog.enabled = !fogInReflection;
                }
				
				if(RenderReflectionCustom != null)
				{
                    //If using a custom method
                    //Destroy the camera if already created as its no longer needed.
                    if (data.reflection.cam != null)
                        data.reflection.DestroyTargets();

                    CreateRenderTarget(data.reflection, cam.pixelWidth, cam.pixelHeight, cam.allowHDR, false, data.settings);

                    //Create the dummy object if null
                    if (m_dummy == null)
					{
						m_dummy = new GameObject("Ceto Reflection Dummy Gameobject");
						m_dummy.hideFlags = HideFlags.HideAndDontSave;
					}
					
                    //Set the position of the reflection plane.
					m_dummy.transform.position = new Vector3(0.0f, m_ocean.level, 0.0f);
                    //Copy returned texture in target.
                    Graphics.Blit(RenderReflectionCustom(m_dummy), data.reflection.target0);
                    reflections0 = data.reflection.target0;
                    reflections1 = null; //Custom stero not supported.
				}
				else
				{
                    //Else use normal method.
                    CreateReflectionCameraFor(cam, data.reflection);
                    CreateRenderTarget(data.reflection, cam.pixelWidth, cam.pixelHeight, cam.allowHDR, cam.stereoEnabled, data.settings);

                    if(cam.stereoEnabled)
                    {
                        RenderSteroReflection(data.reflection, cam, data.settings);
                        reflections0 = data.reflection.target0;
                        reflections1 = data.reflection.target1;
                    }
                    else
                    {
                        Shader.DisableKeyword("CETO_STERO_CAMERA");
                        RenderReflection(data.reflection.cam, data.reflection.target0, cam.transform.position, cam.transform.rotation, cam.projectionMatrix, data.settings);
                        reflections0 = data.reflection.target0;
                        reflections1 = null;
                    }

                }

                //The reflections texture should now contain the rendered 
                //reflections for the current cameras view.
				if(reflections0 != null)
				{
					m_imageBlur.BlurIterations = blurIterations;
					m_imageBlur.BlurMode = blurMode;
					m_imageBlur.BlurSpread = blurSpread;
					m_imageBlur.Blur(reflections0);

					Shader.SetGlobalTexture(Ocean.REFLECTION_TEXTURE_NAME0, reflections0);
				}

                if (reflections1 != null)
                {
                    m_imageBlur.BlurIterations = blurIterations;
                    m_imageBlur.BlurMode = blurMode;
                    m_imageBlur.BlurSpread = blurSpread;
                    m_imageBlur.Blur(reflections1);

                    Shader.SetGlobalTexture(Ocean.REFLECTION_TEXTURE_NAME1, reflections1);
                }

                data.reflection.SetViewAsUpdated(cam);

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

		}