From a6106274676b3fad70754aaf412f2280c550b3a6 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. --- .../Sky/HDLightingWindowEnvironmentSection.cs | 17 +++++++++++------ .../Runtime/Sky/SkyManager.cs | 11 ++++------- 2 files changed, 15 insertions(+), 13 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 009c168b822..5bfb71d8ac4 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 06d54830607..a68ed110d27 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs @@ -828,13 +828,10 @@ 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; - m_StaticLightingSky.cloudLayer = staticLightingSky.cloudLayer; - 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; + m_StaticLightingSky.cloudLayer = staticLightingSky != null ? staticLightingSky.cloudLayer : null; + UpdateEnvironment(hdCamera, renderContext, m_StaticLightingSky, sunLight, m_StaticSkyUpdateRequired, true, true, SkyAmbientMode.Static, frameIndex, cmd); + m_StaticSkyUpdateRequired = false; } m_UpdateRequired = false; From 4d22fbe32d472cbc326b49b6c85930fe95604cfc Mon Sep 17 00:00:00 2001 From: Julien Ignace Date: Fri, 19 Jun 2020 11:57:15 +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 82e1442dfbf..d9d28074993 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -692,6 +692,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed warning in HDAdditionalLightData OnValidate (cases 1250864, 1244578) - Fixed a bug related to denoising ray traced reflections. - Fixed nullref in the layered lit material inspector. +- Fixed an issue where static sky lighting would not be updated for a new scene until it's reloaded at least once. ### Changed - Improve MIP selection for decals on Transparents