From 8d9175361d6c86631d093d3899f69bdd60065f6f Mon Sep 17 00:00:00 2001 From: FrancescoC-Unity Date: Tue, 30 Jun 2020 15:53:13 +0200 Subject: [PATCH 1/3] Fix exception spam --- .../Runtime/Lighting/Reflection/HDProbe.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbe.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbe.cs index 18024aed0ee..dc623d86938 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbe.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbe.cs @@ -186,7 +186,7 @@ public Texture customTexture /// public RenderTexture realtimeTexture { - get => m_RealtimeTexture != null ? m_RealtimeTexture : null; + get => m_RealtimeTexture != null ? m_RealtimeTexture.rt : null; set { if (m_RealtimeTexture != null) @@ -238,7 +238,7 @@ public Texture GetTexture(ProbeSettings.Mode targetMode) { case ProbeSettings.Mode.Baked: return m_BakedTexture; case ProbeSettings.Mode.Custom: return m_CustomTexture; - case ProbeSettings.Mode.Realtime: return m_RealtimeTexture; + case ProbeSettings.Mode.Realtime: return realtimeTexture; default: throw new ArgumentOutOfRangeException(); } } From e4787a5b76a4dc25fe6361e0b937b3124fd5aabd Mon Sep 17 00:00:00 2001 From: FrancescoC-Unity Date: Tue, 30 Jun 2020 16:01:18 +0200 Subject: [PATCH 2/3] Revert "Fix exception spam" This reverts commit 8d9175361d6c86631d093d3899f69bdd60065f6f. --- .../Runtime/Lighting/Reflection/HDProbe.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbe.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbe.cs index dc623d86938..18024aed0ee 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbe.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbe.cs @@ -186,7 +186,7 @@ public Texture customTexture /// public RenderTexture realtimeTexture { - get => m_RealtimeTexture != null ? m_RealtimeTexture.rt : null; + get => m_RealtimeTexture != null ? m_RealtimeTexture : null; set { if (m_RealtimeTexture != null) @@ -238,7 +238,7 @@ public Texture GetTexture(ProbeSettings.Mode targetMode) { case ProbeSettings.Mode.Baked: return m_BakedTexture; case ProbeSettings.Mode.Custom: return m_CustomTexture; - case ProbeSettings.Mode.Realtime: return realtimeTexture; + case ProbeSettings.Mode.Realtime: return m_RealtimeTexture; default: throw new ArgumentOutOfRangeException(); } } From 2f5e2d1c5a6807e45b59ac1bbbfb5231ae4edc82 Mon Sep 17 00:00:00 2001 From: FrancescoC-Unity Date: Tue, 30 Jun 2020 16:01:38 +0200 Subject: [PATCH 3/3] Fix exception on null RTHandle at the root of the problem. --- .../Runtime/Textures/RTHandle.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/com.unity.render-pipelines.core/Runtime/Textures/RTHandle.cs b/com.unity.render-pipelines.core/Runtime/Textures/RTHandle.cs index c540dbb85be..251403878d6 100644 --- a/com.unity.render-pipelines.core/Runtime/Textures/RTHandle.cs +++ b/com.unity.render-pipelines.core/Runtime/Textures/RTHandle.cs @@ -68,6 +68,10 @@ internal RTHandle(RTHandleSystem owner) /// RenderTexture representation of the RTHandle. public static implicit operator RenderTexture(RTHandle handle) { + // If RTHandle is null then conversion should give a null RenderTexture + if (handle == null) + return null; + Debug.Assert(handle.rt != null, "RTHandle was created using a regular Texture and is used as a RenderTexture"); return handle.rt; } @@ -79,6 +83,10 @@ public static implicit operator RenderTexture(RTHandle handle) /// Texture representation of the RTHandle. public static implicit operator Texture(RTHandle handle) { + // If RTHandle is null then conversion should give a null Texture + if (handle == null) + return null; + Debug.Assert(handle.m_ExternalTexture != null || handle.rt != null); return (handle.rt != null) ? handle.rt : handle.m_ExternalTexture; }