private void DoPlanarReflections(ScriptableRenderContext context, Camera camera) { /* If reference position and proxy position is exactly the same, we end up in some degeneracies triggered * by engine code when computing culling parameters. This is an extremely rare case, but can happen * in editor when focusing on the planar probe. So if that happens, we offset them 0.1 mm apart. * if(Vector3.Distance(result.proxyPosition, referencePosition) < 1e-4f) * { * referencePosition += new Vector3(1e-4f, 1e-4f, 1e-4f); * }*/ if (camera.cameraType == CameraType.Reflection || camera.cameraType == CameraType.Preview) { return; } if (!reflectionTarget) { return; } UpdateReflectionCamera(camera); CreateReflectionTexture(camera); var data = new PlanarReflectionSettingData(); data.Set(); BeginPlanarReflections?.Invoke(context, _reflectionCamera); if (_reflectionCamera.WorldToViewportPoint(reflectionTarget.transform.position).z < 100000) { UniversalRenderPipeline.RenderSingleCamera(context, _reflectionCamera); } data.Restore(); Shader.SetGlobalTexture(_planarReflectionTextureId, _reflectionTexture); }
private void ExecutePlanarReflections(ScriptableRenderContext context, Camera camera) { if (!enableReflections) { Cleanup(); return; } if (camera.cameraType == CameraType.Reflection || camera.cameraType == CameraType.Preview || material == null || material.shader.name == "Shader Graphs/Stylized Water For URP Mobile") { return; } UpdateReflectionCamera(camera); ReflectionTexture(camera); var data = new PlanarReflectionSettingData(); data.Set(); BeginPlanarReflections?.Invoke(context, _reflectionCamera); UniversalRenderPipeline.RenderSingleCamera(context, _reflectionCamera); data.Restore(); Shader.SetGlobalTexture(_planarReflectionTextureId, _reflectionTexture); }
/// <summary> /// Executes the planar reflections functions /// </summary> /// <param name="context"></param> /// <param name="cam"></param> public void ExecutePlanarReflections(ScriptableRenderContext context, Camera cam) { if (m_settings.m_disableSkyboxReflections) { return; } if (cam.cameraType == CameraType.Reflection || cam.cameraType == CameraType.Preview) { return; } UpdateReflectionCamera(cam); PlanarReflectionTexture(); if (m_reflectionData == null) { m_reflectionData = new PlanarReflectionSettingData(); } m_reflectionData.Get(); m_reflectionData.Set(); BeginPlanarReflections?.Invoke(context, m_reflectionCamera); #if UPPipeline UniversalRenderPipeline.RenderSingleCamera(context, m_reflectionCamera); #endif PWS_WaterSystem.Instance.SetReflectionTexture(m_reflectionTexture); m_reflectionData.Restore(); }
private void ExecutePlanarReflections(ScriptableRenderContext context, Camera camera) { // we dont want to render planar reflections in reflections or previews if (camera.cameraType == CameraType.Reflection || camera.cameraType == CameraType.Preview) { return; } UpdateReflectionCamera(camera); // create reflected camera PlanarReflectionTexture(camera); // create and assign RenderTexture var data = new PlanarReflectionSettingData(); // save quality settings and lower them for the planar reflections data.Set(); // set quality settings BeginPlanarReflections?.Invoke(context, _reflectionCamera); // callback Action for PlanarReflection UniversalRenderPipeline.RenderSingleCamera(context, _reflectionCamera); // render planar reflections data.Restore(); // restore the quality settings Shader.SetGlobalTexture(_planarReflectionTextureId, _reflectionTexture); // Assign texture to water shader }