From 69ad1db888f6baf292888e85491bf92f4556613e Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Tue, 14 Apr 2020 18:04:49 +0200 Subject: [PATCH 1/3] Fix culling of reflection probes that change position --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Runtime/Lighting/Reflection/HDProbeSystem.cs | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index ce982cb32dc..eff307f8a3f 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -526,6 +526,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fix precise fresnel for delta lights for SVBRDF in AxF. - Fixed the debug exposure mode for display sky reflection and debug view baked lighting - Fixed MSAA depth resolve when there is no motion vectors +- Fixed culling of planar reflection probes that change position (case 1218651) ### Changed - Color buffer pyramid is not allocated anymore if neither refraction nor distortion are enabled diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeSystem.cs index 4dab12b248a..19eb6490b53 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeSystem.cs @@ -246,7 +246,7 @@ internal HDProbeCullState PrepareCull(Camera camera) if (m_PlanarProbeCullingGroup == null) return default; - RemoveDestroyedProbes(m_PlanarProbes, m_PlanarProbeBounds, ref m_PlanarProbeCount); + UpdateBoundsAndRemoveDestroyedProbes(m_PlanarProbes, m_PlanarProbeBounds, ref m_PlanarProbeCount); m_PlanarProbeCullingGroup.targetCamera = camera; m_PlanarProbeCullingGroup.SetBoundingSpheres(m_PlanarProbeBounds); @@ -286,17 +286,17 @@ static void RemoveDestroyedProbes(List probes) } } - static void RemoveDestroyedProbes(PlanarReflectionProbe[] probes, BoundingSphere[] bounds, ref int count) + static void UpdateBoundsAndRemoveDestroyedProbes(PlanarReflectionProbe[] probes, BoundingSphere[] bounds, ref int count) { for (int i = 0; i < count; ++i) { if (probes[i] == null || probes[i].Equals(null)) { probes[i] = probes[count - 1]; - bounds[i] = bounds[count - 1]; probes[count - 1] = null; --count; } + bounds[i] = probes[i].boundingSphere; } } From aa1816f70e6fbf4de04dc6df746d5850a3a06344 Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Tue, 14 Apr 2020 19:01:44 +0200 Subject: [PATCH 2/3] Avoid null reference --- .../Runtime/Lighting/Reflection/HDProbeSystem.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeSystem.cs index 19eb6490b53..35a6f7e9b9d 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeSystem.cs @@ -293,10 +293,14 @@ static void UpdateBoundsAndRemoveDestroyedProbes(PlanarReflectionProbe[] probes, if (probes[i] == null || probes[i].Equals(null)) { probes[i] = probes[count - 1]; + bounds[i] = bounds[count - 1]; probes[count - 1] = null; --count; } - bounds[i] = probes[i].boundingSphere; + else + { + bounds[i] = probes[i].boundingSphere; + } } } From de92a2214c0fd6b678da625de91b7628bbfe0289 Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Tue, 14 Apr 2020 19:11:46 +0200 Subject: [PATCH 3/3] Avoid null reference - try 2 --- .../Runtime/Lighting/Reflection/HDProbeSystem.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeSystem.cs index 35a6f7e9b9d..5a2bcc6dac5 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeSystem.cs @@ -297,7 +297,8 @@ static void UpdateBoundsAndRemoveDestroyedProbes(PlanarReflectionProbe[] probes, probes[count - 1] = null; --count; } - else + + if (probes[i]) { bounds[i] = probes[i].boundingSphere; }