Skip to content

Fixed an issue where static sky lighting would not be updated for a new scene until it's reloaded at least once. #983

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 4 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 @@ -693,6 +693,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed a bug related to denoising ray traced reflections.
- Fixed nullref in the layered lit material inspector.
- 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
- Improve MIP selection for decals on Transparents
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 @@ -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;
Expand Down