Skip to content

[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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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"
{
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down