From ac93e17237a154c114c756436d2701952cf6a8a5 Mon Sep 17 00:00:00 2001 From: anisunity <42026998+anisunity@users.noreply.github.com> Date: Fri, 3 Apr 2020 12:22:10 +0200 Subject: [PATCH 1/9] [7.x.x Backport] Fixed a weird behavior in the scalable settings drawing when the space becomes tiny (1212045). (#6507) * - Fixed a weird behavior in the scalable settings drawing when the space becomes tiny (1212045). * Small fix to avoid text overlapping too much Co-authored-by: Remi Chapelain --- .../CHANGELOG.md | 1 + .../Settings/SerializedScalableSetting.cs | 60 +++++++++++++------ 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 6cc7b8f936b..deb9311e71e 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed drag area width at left of Light's intensity field in Inspector. - Fix for issue that prevented scene from being completely saved when baked reflection probes are present and lighting is set to auto generate. - Fixed the depth buffer copy made before custom pass after opaque and normal injection point. +- Fixed a weird behavior in the scalable settings drawing when the space becomes tiny (1212045). ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedScalableSetting.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedScalableSetting.cs index 29ffffe21c3..ddf918b1a6a 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedScalableSetting.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedScalableSetting.cs @@ -136,29 +136,55 @@ ScalableSettingSchema schema static void MultiField(Rect position, GUIContent[] subLabels, T[] values) where T: struct { + // The number of slots we need to fit into this rectangle var length = values.Length; - var num = (position.width - (float) (length - 1) * 3f) / (float) length; - var position1 = new Rect(position) - { - width = num - }; - var labelWidth = EditorGUIUtility.labelWidth; + + // Let's compute the space allocated for every field including the label + var num = position.width / (float) length; + + // Reset the indentation var indentLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; + + // Variable to keep track of the current pixel shift in the rectangle we were assigned for this whole section. + float pixelShift = 0; + + // Loop through the levels for (var index = 0; index < values.Length; ++index) { - EditorGUIUtility.labelWidth = CalcPrefixLabelWidth(subLabels[index], (GUIStyle) null); - if (typeof(T) == typeof(int)) - values[index] = (T)(object)EditorGUI.DelayedIntField(position1, subLabels[index], (int)(object)values[index]); - else if (typeof(T) == typeof(bool)) - values[index] = (T)(object)EditorGUI.Toggle(position1, subLabels[index], (bool)(object)values[index]); - else if (typeof(T) == typeof(float)) - values[index] = (T)(object)EditorGUI.FloatField(position1, subLabels[index], (float)(object)values[index]); - else - throw new ArgumentOutOfRangeException($"<{typeof(T)}> is not a supported type for multi field"); - position1.x += num + 4f; + // Let's first compute what is the width of the label of this scalable setting level + // We make sure that the label doesn't go beyond the space available for this scalable setting level + var labelWidth = Mathf.Clamp(CalcPrefixLabelWidth(subLabels[index], (GUIStyle)null), 0, num); + + // Draw the Label at the expected position + EditorGUI.LabelField(new Rect(position.x + pixelShift, position.y, labelWidth, position.height), subLabels[index]); + + // We need to remove from the position the label size that we've just drawn and shift by it's length + pixelShift += labelWidth; + + // The amount of space left for the field + float spaceLeft = num - labelWidth; + + // If at least two pixels are left to draw this field, draw it, otherwise, skip + if (spaceLeft > 2) + { + // Define the rectangle for the field + var fieldSlot = new Rect(position.x + pixelShift, position.y, num - labelWidth, position.height); + + // Draw the right field depending on its type. + if (typeof(T) == typeof(int)) + values[index] = (T)(object)EditorGUI.DelayedIntField(fieldSlot, (int)(object)values[index]); + else if (typeof(T) == typeof(bool)) + values[index] = (T)(object)EditorGUI.Toggle(fieldSlot, (bool)(object)values[index]); + else if (typeof(T) == typeof(float)) + values[index] = (T)(object)EditorGUI.FloatField(fieldSlot, (float)(object)values[index]); + else + throw new ArgumentOutOfRangeException($"<{typeof(T)}> is not a supported type for multi field"); + } + + // Shift by the slot that was left for the field + pixelShift += spaceLeft; } - EditorGUIUtility.labelWidth = labelWidth; EditorGUI.indentLevel = indentLevel; } From f4f74f13bd2641fef829e0e212e8fcc06f60ccab Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Tue, 7 Apr 2020 11:24:50 +0200 Subject: [PATCH 2/9] Fixed an usage of a a compute buffer not bound (1229964) (#28) Co-authored-by: Anis --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Runtime/Lighting/LightLoop/LightLoop.cs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index deb9311e71e..3750842ffaa 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fix for issue that prevented scene from being completely saved when baked reflection probes are present and lighting is set to auto generate. - Fixed the depth buffer copy made before custom pass after opaque and normal injection point. - Fixed a weird behavior in the scalable settings drawing when the space becomes tiny (1212045). +- Fixed an usage of a a compute buffer not bound (1229964) ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs index e00440045ef..253b45ecd8a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs @@ -3150,7 +3150,8 @@ void BuildGPULightListsCommon(HDCamera hdCamera, CommandBuffer cmd) // Note we clear the whole content and not just the header since it is fast enough, happens only in one frame and is a bit more robust // to changes to the inner workings of the lists. // Also, we clear all the lists and to be resilient to changes in pipeline. - ClearLightList(hdCamera, cmd, resources.tileAndClusterData.bigTileLightList); + if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.BigTilePrepass)) + ClearLightList(hdCamera, cmd, resources.tileAndClusterData.bigTileLightList); ClearLightList(hdCamera, cmd, resources.tileAndClusterData.lightList); ClearLightList(hdCamera, cmd, resources.tileAndClusterData.perVoxelOffset); From 5ddc5f7d57402d8d02dcbec132714e1103d1d222 Mon Sep 17 00:00:00 2001 From: JulienIgnace-Unity Date: Fri, 3 Apr 2020 12:16:21 +0200 Subject: [PATCH 3/9] Removed wrongly serialized fields in StaticLightingSky (#6441) --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Runtime/Sky/StaticLightingSky.cs | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 3750842ffaa..acc501d6d50 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed the depth buffer copy made before custom pass after opaque and normal injection point. - Fixed a weird behavior in the scalable settings drawing when the space becomes tiny (1212045). - Fixed an usage of a a compute buffer not bound (1229964) +- Fixed an issue where unncessarily serialized members in StaticLightingSky component would change each time the scene is changed. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/StaticLightingSky.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/StaticLightingSky.cs index 2736cfcf1c4..38611f3af22 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/StaticLightingSky.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/StaticLightingSky.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using UnityEngine.Serialization; @@ -15,8 +16,9 @@ class StaticLightingSky : MonoBehaviour int m_LastComputedHash; bool m_NeedUpdateStaticLightingSky; - // This one contain only property values from overridden properties in the original profile component - public SkySettings m_SkySettings; + [NonSerialized] + public SkySettings m_SkySettings; // This one contain only property values from overridden properties in the original profile component + [NonSerialized] public SkySettings m_SkySettingsFromProfile; public SkySettings skySettings From 5faae4d30c5215a9388debbc8ee3d43937b3ec5c Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Tue, 7 Apr 2020 20:53:55 +0200 Subject: [PATCH 4/9] Fix issues in the post process system with RenderTexture being invalid in some cases. Causing rendering problems. #6480 --- .../CHANGELOG.md | 1 + .../PostProcessing/PostProcessSystem.cs | 74 +++++++++++++++++-- 2 files changed, 69 insertions(+), 6 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index acc501d6d50..e9e42b0a523 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed a weird behavior in the scalable settings drawing when the space becomes tiny (1212045). - Fixed an usage of a a compute buffer not bound (1229964) - Fixed an issue where unncessarily serialized members in StaticLightingSky component would change each time the scene is changed. +- Fix issues in the post process system with RenderTexture being invalid in some cases, causing rendering problems. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs index 615d2af76bd..a04f91e90b3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs @@ -133,6 +133,15 @@ private enum SMAAStage HDRenderPipeline m_HDInstance; + void FillEmptyExposureTexture() + { + var tex = new Texture2D(1, 1, TextureFormat.RGHalf, false, true); + tex.SetPixel(0, 0, new Color(1f, ColorUtils.ConvertExposureToEV100(1f), 0f, 0f)); + tex.Apply(); + Graphics.Blit(tex, m_EmptyExposureTexture); + CoreUtils.Destroy(tex); + } + public PostProcessSystem(HDRenderPipelineAsset hdAsset, RenderPipelineResources defaultResources) { m_Resources = defaultResources; @@ -206,11 +215,7 @@ public PostProcessSystem(HDRenderPipelineAsset hdAsset, RenderPipelineResources // TODO: Write a version that uses structured buffer instead of texture to do atomic as Metal doesn't support atomics on textures. m_MotionBlurSupportsScattering = m_MotionBlurSupportsScattering && (SystemInfo.graphicsDeviceType != GraphicsDeviceType.Metal); - var tex = new Texture2D(1, 1, TextureFormat.RGHalf, false, true); - tex.SetPixel(0, 0, new Color(1f, ColorUtils.ConvertExposureToEV100(1f), 0f, 0f)); - tex.Apply(); - Graphics.Blit(tex, m_EmptyExposureTexture); - CoreUtils.Destroy(tex); + FillEmptyExposureTexture(); // Initialize our target pool to ease RT management m_Pool = new TargetPool(); @@ -287,6 +292,23 @@ public void Cleanup() m_FarBokehTileList = null; } + // In some cases, the internal buffer of render textures might be invalid. + // Usually when using these textures with API such as SetRenderTarget, they are recreated internally. + // This is not the case when these textures are used exclusively with Compute Shaders. So to make sure they work in this case, we recreate them here. + void CheckRenderTexturesValidity() + { + if (!m_EmptyExposureTexture.rt.IsCreated()) + FillEmptyExposureTexture(); + + HDUtils.CheckRTCreated(m_InternalLogLut.rt); + HDUtils.CheckRTCreated(m_TempTexture1024.rt); + HDUtils.CheckRTCreated(m_TempTexture32.rt); + if (m_KeepAlpha) + { + HDUtils.CheckRTCreated(m_AlphaTexture.rt); + } + } + public void BeginFrame(CommandBuffer cmd, HDCamera camera, HDRenderPipeline hdInstance) { m_HDInstance = hdInstance; @@ -336,6 +358,8 @@ public void BeginFrame(CommandBuffer cmd, HDCamera camera, HDRenderPipeline hdIn m_DitheringFS = frameSettings.IsEnabled(FrameSettingsField.Dithering); m_AntialiasingFS = frameSettings.IsEnabled(FrameSettingsField.Antialiasing); + CheckRenderTexturesValidity(); + // Handle fixed exposure & disabled pre-exposure by forcing an exposure multiplier of 1 if (!m_ExposureControlFS) { @@ -929,6 +953,40 @@ void DoTemporalAntialiasing(CommandBuffer cmd, HDCamera camera, RTHandle source, m_TAAPropertyBlock.SetVector(HDShaderIDs._RTHandleScaleHistory, camera.historyRTHandleProperties.rtHandleScale); m_TAAPropertyBlock.SetTexture(HDShaderIDs._InputTexture, source); m_TAAPropertyBlock.SetTexture(HDShaderIDs._InputHistoryTexture, prevHistory); +<<<<<<< HEAD +======= + m_TAAPropertyBlock.SetTexture(HDShaderIDs._InputVelocityMagnitudeHistory, prevMVLen); + + m_TAAPropertyBlock.SetTexture(HDShaderIDs._DepthTexture, depthMipChain); + + float minAntiflicker = 0.0f; + float maxAntiflicker = 3.5f; + float motionRejectionMultiplier = Mathf.Lerp(0.0f, 250.0f, camera.taaMotionVectorRejection * camera.taaMotionVectorRejection * camera.taaMotionVectorRejection); + + var taaParameters = new Vector4(camera.taaHistorySharpening, Mathf.Lerp(minAntiflicker, maxAntiflicker, camera.taaAntiFlicker), motionRejectionMultiplier, 0.0f); + Vector2 historySize = new Vector2(prevHistory.referenceSize.x * prevHistory.scaleFactor.x, + prevHistory.referenceSize.y * prevHistory.scaleFactor.y); + var rtScaleForHistory = camera.historyRTHandleProperties.rtHandleScale; + var taaHistorySize = new Vector4(historySize.x, historySize.y, 1.0f / historySize.x, 1.0f / historySize.y); + + // Precompute weights used for the Blackman-Harris filter. TODO: Note that these are slightly wrong as they don't take into account the jitter size. This needs to be fixed at some point. + float crossWeights = Mathf.Exp(-2.29f * 2); + float plusWeights = Mathf.Exp(-2.29f); + float centerWeight = 1; + + float totalWeight = centerWeight + (4 * plusWeights); + if (camera.TAAQuality == HDAdditionalCameraData.TAAQualityLevel.High) + { + totalWeight += crossWeights * 4; + } + + // Weights will be x: central, y: plus neighbours, z: cross neighbours, w: total + Vector4 taaFilterWeights = new Vector4(centerWeight / totalWeight, plusWeights / totalWeight, crossWeights / totalWeight, totalWeight); + + m_TAAPropertyBlock.SetVector(HDShaderIDs._TaaPostParameters, taaParameters); + m_TAAPropertyBlock.SetVector(HDShaderIDs._TaaHistorySize, taaHistorySize); + m_TAAPropertyBlock.SetVector(HDShaderIDs._TaaFilterWeights, taaFilterWeights); +>>>>>>> 968d203cb6... Fix issues in the post process system with RenderTexture being invalid in some cases. Causing rendering problems. (#6480) CoreUtils.SetRenderTarget(cmd, destination, depthBuffer); cmd.SetRandomWriteTarget(1, nextHistory); @@ -2644,7 +2702,11 @@ public RTHandle Get(in Vector2 scaleFactor, GraphicsFormat format, bool mipmap = var hashCode = ComputeHashCode(scaleFactor.x, scaleFactor.y, (int)format, mipmap); if (m_Targets.TryGetValue(hashCode, out var stack) && stack.Count > 0) - return stack.Pop(); + { + var tex = stack.Pop(); + HDUtils.CheckRTCreated(tex.rt); + return tex; + } var rt = RTHandles.Alloc( scaleFactor, TextureXR.slices, DepthBits.None, colorFormat: format, dimension: TextureXR.dimension, From 3531a5791d9d79ddd36b11d5e9515805b2186bea Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Tue, 7 Apr 2020 21:14:10 +0200 Subject: [PATCH 5/9] Update PostProcessSystem.cs --- .../PostProcessing/PostProcessSystem.cs | 34 ------------------- 1 file changed, 34 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs index a04f91e90b3..1f419daff06 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs @@ -953,40 +953,6 @@ void DoTemporalAntialiasing(CommandBuffer cmd, HDCamera camera, RTHandle source, m_TAAPropertyBlock.SetVector(HDShaderIDs._RTHandleScaleHistory, camera.historyRTHandleProperties.rtHandleScale); m_TAAPropertyBlock.SetTexture(HDShaderIDs._InputTexture, source); m_TAAPropertyBlock.SetTexture(HDShaderIDs._InputHistoryTexture, prevHistory); -<<<<<<< HEAD -======= - m_TAAPropertyBlock.SetTexture(HDShaderIDs._InputVelocityMagnitudeHistory, prevMVLen); - - m_TAAPropertyBlock.SetTexture(HDShaderIDs._DepthTexture, depthMipChain); - - float minAntiflicker = 0.0f; - float maxAntiflicker = 3.5f; - float motionRejectionMultiplier = Mathf.Lerp(0.0f, 250.0f, camera.taaMotionVectorRejection * camera.taaMotionVectorRejection * camera.taaMotionVectorRejection); - - var taaParameters = new Vector4(camera.taaHistorySharpening, Mathf.Lerp(minAntiflicker, maxAntiflicker, camera.taaAntiFlicker), motionRejectionMultiplier, 0.0f); - Vector2 historySize = new Vector2(prevHistory.referenceSize.x * prevHistory.scaleFactor.x, - prevHistory.referenceSize.y * prevHistory.scaleFactor.y); - var rtScaleForHistory = camera.historyRTHandleProperties.rtHandleScale; - var taaHistorySize = new Vector4(historySize.x, historySize.y, 1.0f / historySize.x, 1.0f / historySize.y); - - // Precompute weights used for the Blackman-Harris filter. TODO: Note that these are slightly wrong as they don't take into account the jitter size. This needs to be fixed at some point. - float crossWeights = Mathf.Exp(-2.29f * 2); - float plusWeights = Mathf.Exp(-2.29f); - float centerWeight = 1; - - float totalWeight = centerWeight + (4 * plusWeights); - if (camera.TAAQuality == HDAdditionalCameraData.TAAQualityLevel.High) - { - totalWeight += crossWeights * 4; - } - - // Weights will be x: central, y: plus neighbours, z: cross neighbours, w: total - Vector4 taaFilterWeights = new Vector4(centerWeight / totalWeight, plusWeights / totalWeight, crossWeights / totalWeight, totalWeight); - - m_TAAPropertyBlock.SetVector(HDShaderIDs._TaaPostParameters, taaParameters); - m_TAAPropertyBlock.SetVector(HDShaderIDs._TaaHistorySize, taaHistorySize); - m_TAAPropertyBlock.SetVector(HDShaderIDs._TaaFilterWeights, taaFilterWeights); ->>>>>>> 968d203cb6... Fix issues in the post process system with RenderTexture being invalid in some cases. Causing rendering problems. (#6480) CoreUtils.SetRenderTarget(cmd, destination, depthBuffer); cmd.SetRandomWriteTarget(1, nextHistory); From 84b722da62ff2a385c4af7fa0b3688e49741d083 Mon Sep 17 00:00:00 2001 From: JulienIgnace-Unity Date: Fri, 3 Apr 2020 12:14:50 +0200 Subject: [PATCH 6/9] Fixed an issue where changing the default volume profile from another inspector would not update the default volume editor. #6493 --- .../Editor/Volume/VolumeComponentListEditor.cs | 15 ++++++++++----- .../Runtime/Volume/VolumeProfile.cs | 18 ++++++++++++++++++ .../CHANGELOG.md | 1 + .../Settings/DefaultSettingsPanel.cs | 14 +++++++++++--- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs b/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs index f487281dc3c..21a110079a0 100644 --- a/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs +++ b/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs @@ -16,24 +16,24 @@ namespace UnityEditor.Rendering /// in the inspector: /// /// using UnityEngine.Rendering; - /// + /// /// [CustomEditor(typeof(VolumeProfile))] /// public class CustomVolumeProfileEditor : Editor /// { /// VolumeComponentListEditor m_ComponentList; - /// + /// /// void OnEnable() /// { /// m_ComponentList = new VolumeComponentListEditor(this); /// m_ComponentList.Init(target as VolumeProfile, serializedObject); /// } - /// + /// /// void OnDisable() /// { /// if (m_ComponentList != null) /// m_ComponentList.Clear(); /// } - /// + /// /// public override void OnInspectorGUI() /// { /// serializedObject.Update(); @@ -58,6 +58,8 @@ public sealed class VolumeComponentListEditor Dictionary m_EditorTypes; // Component type => Editor type List m_Editors; + int m_CurrentHashCode; + /// /// Creates a new instance of to use in an /// existing editor. @@ -195,9 +197,12 @@ public void OnGUI() if (asset == null) return; - if (asset.isDirty) + // Even if the asset is not dirty, the list of component may have been changed by another inspector. + // In this case, only the hash will tell us that we need to refresh. + if (asset.isDirty || asset.GetHashCode() != m_CurrentHashCode) { RefreshEditors(); + m_CurrentHashCode = asset.GetHashCode(); asset.isDirty = false; } diff --git a/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs b/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs index 31a3f01272a..127ae880810 100644 --- a/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs +++ b/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs @@ -279,5 +279,23 @@ public bool TryGetAllSubclassOf(Type type, List result) return count != result.Count; } + + + /// + /// A custom hashing function that Unity uses to compare the state of parameters. + /// + /// A computed hash code for the current instance. + public override int GetHashCode() + { + unchecked + { + int hash = 17; + + for (int i = 0; i < components.Count; i++) + hash = hash * 23 + components[i].GetHashCode(); + + return hash; + } + } } } diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index e9e42b0a523..25b769d58c2 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed an usage of a a compute buffer not bound (1229964) - Fixed an issue where unncessarily serialized members in StaticLightingSky component would change each time the scene is changed. - Fix issues in the post process system with RenderTexture being invalid in some cases, causing rendering problems. +- Fixed an issue where changing the default volume profile from another inspector would not update the default volume editor. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs index 1018c140941..b244d14d284 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs @@ -45,6 +45,7 @@ public class Styles ReorderableList m_BeforeTransparentCustomPostProcesses; ReorderableList m_BeforePostProcessCustomPostProcesses; ReorderableList m_AfterPostProcessCustomPostProcesses; + int m_CurrentVolumeProfileHash; public void OnGUI(string searchContext) { @@ -207,6 +208,13 @@ void Draw_VolumeInspector() } EditorGUILayout.EndHorizontal(); + // The state of the profile can change without the asset reference changing so in this case we need to reset the editor. + if (m_CurrentVolumeProfileHash != asset.GetHashCode() && m_CachedDefaultVolumeProfileEditor != null) + { + m_CurrentVolumeProfileHash = asset.GetHashCode(); + m_CachedDefaultVolumeProfileEditor = null; + } + Editor.CreateCachedEditor(asset, Type.GetType("UnityEditor.Rendering.VolumeProfileEditor"), ref m_CachedDefaultVolumeProfileEditor); EditorGUIUtility.labelWidth -= 18; bool oldEnabled = GUI.enabled; @@ -230,13 +238,13 @@ void Draw_VolumeInspector() hdrpAsset.defaultLookDevProfile = newLookDevAsset; EditorUtility.SetDirty(hdrpAsset); } - + if (GUILayout.Button(EditorGUIUtility.TrTextContent("New", "Create a new Volume Profile for default in your default resource folder (defined in Wizard)"), GUILayout.Width(38), GUILayout.Height(18))) { DefaultVolumeProfileCreator.CreateAndAssign(DefaultVolumeProfileCreator.Kind.LookDev); } EditorGUILayout.EndHorizontal(); - + Editor.CreateCachedEditor(lookDevAsset, Type.GetType("UnityEditor.Rendering.VolumeProfileEditor"), ref m_CachedLookDevVolumeProfileEditor); EditorGUIUtility.labelWidth -= 18; oldEnabled = GUI.enabled; @@ -311,7 +319,7 @@ static string GetDefaultName(Kind kind) } return defaultName; } - + public static void CreateAndAssign(Kind kind) { var assetCreator = ScriptableObject.CreateInstance(); From 0cd029919edb82f4c394e135f3ef29e926db8946 Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Thu, 2 Apr 2020 11:15:43 +0100 Subject: [PATCH 7/9] Hdrp/docs/glossary f number (#6523) * Update Glossary.md * Update Glossary.md --- .../Documentation~/Glossary.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Glossary.md b/com.unity.render-pipelines.high-definition/Documentation~/Glossary.md index 93c340fad87..65bbdd53b8e 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Glossary.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Glossary.md @@ -40,7 +40,7 @@ A face refers to one side of a piece of geometry. The front face is the side of #### f-number: -The ratio of the focal length to the diameter of the camera lens. +The ratio of the focal length to the diameter of the camera lens. HDRP technically uses [t-number](https://en.wikipedia.org/wiki/F-number#T-stop), but since Cameras in Unity are optically perfect, f-number and t-number are identical. From accff861218da0672b0700356722a58ef5c8949f Mon Sep 17 00:00:00 2001 From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com> Date: Tue, 7 Apr 2020 19:32:29 +0200 Subject: [PATCH 8/9] Clamp probes compression factor to 0 (#19) --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Runtime/Utilities/ProbeSettings.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 25b769d58c2..3d5d5675c61 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed an issue where unncessarily serialized members in StaticLightingSky component would change each time the scene is changed. - Fix issues in the post process system with RenderTexture being invalid in some cases, causing rendering problems. - Fixed an issue where changing the default volume profile from another inspector would not update the default volume editor. +- Fix for range compression factor for probes going negative (now clamped to positive values). ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeSettings.cs index 23499318e19..23360c346f5 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeSettings.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeSettings.cs @@ -137,6 +137,7 @@ public struct Lighting public float fadeDistance; /// The result of the rendering of the probe will be divided by this factor. When the probe is read, this factor is undone as the probe data is read. /// This is to simply avoid issues with values clamping due to precision of the storing format. + [Min(1e-6f)] public float rangeCompressionFactor; } From b754f52b3cc3dc1d97215fc3051d8e9a4cc32548 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Wed, 8 Apr 2020 00:15:55 +0200 Subject: [PATCH 9/9] path validation when creating new volume profile (#36) --- .../Editor/Volume/VolumeProfileFactory.cs | 16 +++++++++++++--- .../CHANGELOG.md | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.core/Editor/Volume/VolumeProfileFactory.cs b/com.unity.render-pipelines.core/Editor/Volume/VolumeProfileFactory.cs index c9eba822995..cf00102a263 100644 --- a/com.unity.render-pipelines.core/Editor/Volume/VolumeProfileFactory.cs +++ b/com.unity.render-pipelines.core/Editor/Volume/VolumeProfileFactory.cs @@ -56,12 +56,22 @@ public static VolumeProfile CreateVolumeProfile(Scene scene, string targetName) { var scenePath = Path.GetDirectoryName(scene.path); var extPath = scene.name; - var profilePath = scenePath + "/" + extPath; + var profilePath = scenePath + Path.DirectorySeparatorChar + extPath; if (!AssetDatabase.IsValidFolder(profilePath)) - AssetDatabase.CreateFolder(scenePath, extPath); + { + var directories = profilePath.Split(Path.DirectorySeparatorChar); + string rootPath = ""; + foreach (var directory in directories) + { + var newPath = rootPath + directory; + if (!AssetDatabase.IsValidFolder(newPath)) + AssetDatabase.CreateFolder(rootPath.TrimEnd(Path.DirectorySeparatorChar), directory); + rootPath = newPath + Path.DirectorySeparatorChar; + } + } - path = profilePath + "/"; + path = profilePath + Path.DirectorySeparatorChar; } path += targetName + " Profile.asset"; diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 3d5d5675c61..931c4151dd4 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fix issues in the post process system with RenderTexture being invalid in some cases, causing rendering problems. - Fixed an issue where changing the default volume profile from another inspector would not update the default volume editor. - Fix for range compression factor for probes going negative (now clamped to positive values). +- Fixed path validation when creating new volume profile (case 1229933) ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history.