/// <summary> /// Camera pre cull event /// </summary> /// <param name="camera">Camera</param> protected virtual void CameraPreCull(Camera camera) { if (Effect != null && Effect.Enabled && !WeatherMakerScript.ShouldIgnoreCamera(this, camera, !AllowReflections)) { if ((camera.actualRenderingPath == RenderingPath.Forward || camera.actualRenderingPath == RenderingPath.VertexLit)) { #if UNITY_EDITOR if (WeatherMakerScript.GetCameraType(camera) == WeatherMakerCameraType.Normal) { Debug.LogWarning("Full screen overlay works best with deferred shading"); } #endif camera.depthTextureMode |= DepthTextureMode.DepthNormals; } else { camera.depthTextureMode &= (~DepthTextureMode.DepthNormals); } Effect.PreCullCamera(camera, true); } }
private bool ShouldProcessCamera(Camera camera) { return(camera != null && waterCollider != null && waterCollider.enabled && !WeatherMakerScript.ShouldIgnoreCamera(this, camera) && WeatherMakerScript.IsLocalPlayer(camera.transform)); }
private void CameraPreCull(Camera camera) { if (ReflectMaterial == null || camera == null || WeatherMakerLightManagerScript.Instance == null || (ReflectRenderer != null && !ReflectRenderer.enabled) || !gameObject.activeInHierarchy || WeatherMakerCommandBufferManagerScript.CameraStack > 1 || WeatherMakerScript.ShouldIgnoreCamera(this, camera, true)) { return; } // HACK: Reflections need to ensure the frustum planes and corners are up to date. This is normally done in a pre-render // event, but we cannot do that as rendering a reflection in pre-render mucks up state and such WeatherMakerLightManagerScript.Instance.CalculateFrustumPlanes(camera); // this frustum cull test is expensive, but well worth it if it prevents a reflection from needing to be rendered // get up to date frustum info if (ReflectRenderer != null && !WeatherMakerGeometryUtility.BoxIntersectsFrustum(camera, WeatherMakerLightManagerScript.Instance.CurrentCameraFrustumPlanes, WeatherMakerLightManagerScript.Instance.CurrentCameraFrustumCorners, ReflectRenderer.bounds)) { return; } // render the reflection in pre-cull, pre-render is when shader properties and other such things are set Camera reflectionCamera = GetOrCreateReflectionCamera(camera); RenderReflectionCamera(camera, reflectionCamera); }