Skip to content

Commit 1f836e7

Browse files
[Backport 7.x.x] Fixed an issue where static sky lighting would not be updated for a new scene until it's reloaded at least once. (#990)
* 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 * Update changelog
1 parent 7e75729 commit 1f836e7

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

com.unity.render-pipelines.high-definition/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
9292
- Tentative fix for missing include in depth of field shaders.
9393
- Fix an issue in reading the gbuffer for ray traced subsurface scattering (case 1248358).
9494
- Fixed an issue where manipulating the color wheels in a volume component would reset the cursor every time.
95+
- Fixed an issue where static sky lighting would not be updated for a new scene until it's reloaded at least once.
9596

9697
### Changed
9798
- Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history.

com.unity.render-pipelines.high-definition/Editor/Sky/HDLightingWindowEnvironmentSection.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,16 @@ class SerializedStaticLightingSky
3232
{
3333
SerializedObject serializedObject;
3434
public SerializedProperty skyUniqueID;
35-
public SerializedProperty profile;
35+
public VolumeProfile volumeProfile
36+
{
37+
get => (serializedObject.targetObject as StaticLightingSky).profile;
38+
set => (serializedObject.targetObject as StaticLightingSky).profile = value;
39+
}
3640

3741
public SerializedStaticLightingSky(StaticLightingSky staticLightingSky)
3842
{
3943
serializedObject = new SerializedObject(staticLightingSky);
4044
skyUniqueID = serializedObject.FindProperty("m_StaticLightingSkyUniqueID");
41-
profile = serializedObject.FindProperty("m_Profile");
4245
}
4346

4447
public void Apply() => serializedObject.ApplyModifiedProperties();
@@ -170,10 +173,12 @@ void DrawGUI()
170173
++EditorGUI.indentLevel;
171174

172175
//cannot use SerializeProperty due to logic in the property
173-
var profile = m_SerializedActiveSceneLightingSky.profile.objectReferenceValue;
174-
var newProfile = EditorGUILayout.ObjectField(EditorGUIUtility.TrTextContent("Profile"), m_SerializedActiveSceneLightingSky.profile.objectReferenceValue, typeof(VolumeProfile), allowSceneObjects: false) as VolumeProfile;
176+
var profile = m_SerializedActiveSceneLightingSky.volumeProfile;
177+
var newProfile = EditorGUILayout.ObjectField(EditorGUIUtility.TrTextContent("Profile"), profile, typeof(VolumeProfile), allowSceneObjects: false) as VolumeProfile;
175178
if (profile != newProfile)
176-
m_SerializedActiveSceneLightingSky.profile.objectReferenceValue = newProfile;
179+
{
180+
m_SerializedActiveSceneLightingSky.volumeProfile = newProfile;
181+
}
177182

178183
using (new EditorGUI.DisabledScope(m_SkyClassNames.Count == 1)) // Only "None"
179184
{
@@ -200,7 +205,7 @@ void UpdateSkyIntPopupData()
200205
m_SkyClassNames.Add(new GUIContent("None"));
201206
m_SkyUniqueIDs.Add(0);
202207

203-
VolumeProfile profile = m_SerializedActiveSceneLightingSky.profile.objectReferenceValue as VolumeProfile;
208+
VolumeProfile profile = m_SerializedActiveSceneLightingSky.volumeProfile;
204209
if (profile != null)
205210
{
206211
var skyTypesDict = SkyManager.skyTypesDict;

com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -820,12 +820,9 @@ public void UpdateEnvironment(HDCamera hdCamera, ScriptableRenderContext renderC
820820
#endif
821821
if ((ambientMode == SkyAmbientMode.Static || forceStaticUpdate) && hdCamera.camera.cameraType != CameraType.Preview)
822822
{
823-
if (staticLightingSky != null)
824-
{
825-
m_StaticLightingSky.skySettings = staticLightingSky.skySettings;
826-
UpdateEnvironment(hdCamera, renderContext, m_StaticLightingSky, sunLight, m_StaticSkyUpdateRequired, true, true, SkyAmbientMode.Static, frameIndex, cmd);
827-
m_StaticSkyUpdateRequired = false;
828-
}
823+
m_StaticLightingSky.skySettings = staticLightingSky != null ? staticLightingSky.skySettings : null;
824+
UpdateEnvironment(hdCamera, renderContext, m_StaticLightingSky, sunLight, m_StaticSkyUpdateRequired, true, true, SkyAmbientMode.Static, frameIndex, cmd);
825+
m_StaticSkyUpdateRequired = false;
829826
}
830827

831828
m_UpdateRequired = false;

0 commit comments

Comments
 (0)