From a2593e1ed2bb3fad5726f257fee56aaf03035ca4 Mon Sep 17 00:00:00 2001 From: Julien Ignace Date: Fri, 19 Jun 2020 11:56:47 +0200 Subject: [PATCH 1/2] Fixed an issue where static sky lighting would not be updated for a new scene until it's reloaded at least once. # Conflicts: # com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs --- .../Sky/HDLightingWindowEnvironmentSection.cs | 17 +++++++++++------ .../Runtime/Sky/SkyManager.cs | 9 +++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/Sky/HDLightingWindowEnvironmentSection.cs b/com.unity.render-pipelines.high-definition/Editor/Sky/HDLightingWindowEnvironmentSection.cs index 682cba36804..53357c92561 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Sky/HDLightingWindowEnvironmentSection.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Sky/HDLightingWindowEnvironmentSection.cs @@ -32,13 +32,16 @@ class SerializedStaticLightingSky { SerializedObject serializedObject; public SerializedProperty skyUniqueID; - public SerializedProperty profile; + public VolumeProfile volumeProfile + { + get => (serializedObject.targetObject as StaticLightingSky).profile; + set => (serializedObject.targetObject as StaticLightingSky).profile = value; + } public SerializedStaticLightingSky(StaticLightingSky staticLightingSky) { serializedObject = new SerializedObject(staticLightingSky); skyUniqueID = serializedObject.FindProperty("m_StaticLightingSkyUniqueID"); - profile = serializedObject.FindProperty("m_Profile"); } public void Apply() => serializedObject.ApplyModifiedProperties(); @@ -170,10 +173,12 @@ void DrawGUI() ++EditorGUI.indentLevel; //cannot use SerializeProperty due to logic in the property - var profile = m_SerializedActiveSceneLightingSky.profile.objectReferenceValue; - var newProfile = EditorGUILayout.ObjectField(EditorGUIUtility.TrTextContent("Profile"), m_SerializedActiveSceneLightingSky.profile.objectReferenceValue, typeof(VolumeProfile), allowSceneObjects: false) as VolumeProfile; + var profile = m_SerializedActiveSceneLightingSky.volumeProfile; + var newProfile = EditorGUILayout.ObjectField(EditorGUIUtility.TrTextContent("Profile"), profile, typeof(VolumeProfile), allowSceneObjects: false) as VolumeProfile; if (profile != newProfile) - m_SerializedActiveSceneLightingSky.profile.objectReferenceValue = newProfile; + { + m_SerializedActiveSceneLightingSky.volumeProfile = newProfile; + } using (new EditorGUI.DisabledScope(m_SkyClassNames.Count == 1)) // Only "None" { @@ -200,7 +205,7 @@ void UpdateSkyIntPopupData() m_SkyClassNames.Add(new GUIContent("None")); m_SkyUniqueIDs.Add(0); - VolumeProfile profile = m_SerializedActiveSceneLightingSky.profile.objectReferenceValue as VolumeProfile; + VolumeProfile profile = m_SerializedActiveSceneLightingSky.volumeProfile; if (profile != null) { var skyTypesDict = SkyManager.skyTypesDict; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs index ba9ba4d50de..63543b12ea4 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs @@ -820,12 +820,9 @@ public void UpdateEnvironment(HDCamera hdCamera, ScriptableRenderContext renderC #endif if ((ambientMode == SkyAmbientMode.Static || forceStaticUpdate) && hdCamera.camera.cameraType != CameraType.Preview) { - if (staticLightingSky != null) - { - m_StaticLightingSky.skySettings = staticLightingSky.skySettings; - UpdateEnvironment(hdCamera, renderContext, m_StaticLightingSky, sunLight, m_StaticSkyUpdateRequired, true, true, SkyAmbientMode.Static, frameIndex, cmd); - m_StaticSkyUpdateRequired = false; - } + m_StaticLightingSky.skySettings = staticLightingSky != null ? staticLightingSky.skySettings : null; + UpdateEnvironment(hdCamera, renderContext, m_StaticLightingSky, sunLight, m_StaticSkyUpdateRequired, true, true, SkyAmbientMode.Static, frameIndex, cmd); + m_StaticSkyUpdateRequired = false; } m_UpdateRequired = false; From 7745382af0d2f56258be2bb614afaf47c7efbbc4 Mon Sep 17 00:00:00 2001 From: Julien Ignace Date: Fri, 19 Jun 2020 17:53:49 +0200 Subject: [PATCH 2/2] Update changelog --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 5000e81f72d..2e4b7a1fa62 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -92,6 +92,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Tentative fix for missing include in depth of field shaders. - Fix an issue in reading the gbuffer for ray traced subsurface scattering (case 1248358). - Fixed an issue where manipulating the color wheels in a volume component would reset the cursor every time. +- Fixed an issue where static sky lighting would not be updated for a new scene until it's reloaded at least once. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history.