From 13d36e6f0dc8280b8a5c65d66ea00275ddae6e38 Mon Sep 17 00:00:00 2001 From: Kleber Garcia Date: Tue, 23 Feb 2021 22:50:20 -0500 Subject: [PATCH 1/3] Fixing wrong ordering of frame settings on the UI. Ignoring enums that are tagged as obsolete. --- .../Settings/OverridableFrameSettingsArea.cs | 7 +++- .../Debugging/FrameSettingsFieldAttribute.cs | 18 ++++++++- .../RenderPipeline/Settings/FrameSettings.cs | 37 ++++++++++--------- 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/OverridableFrameSettingsArea.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/OverridableFrameSettingsArea.cs index 9c6aa06d2a2..454c031f8b3 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/OverridableFrameSettingsArea.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/OverridableFrameSettingsArea.cs @@ -27,9 +27,12 @@ static OverridableFrameSettingsArea() attributes = new Dictionary(); attributesGroup = new Dictionary>>(); Type type = typeof(FrameSettingsField); - foreach (FrameSettingsField value in Enum.GetValues(type)) + foreach (string enumName in Enum.GetNames(type)) { - attributes[value] = type.GetField(Enum.GetName(type, value)).GetCustomAttribute(); + if (type.GetField(enumName).GetCustomAttribute() != null) + continue; + + attributes[(FrameSettingsField)Enum.Parse(type, enumName)] = type.GetField(enumName).GetCustomAttribute(); } frameSettingsKeywords = attributes diff --git a/com.unity.render-pipelines.high-definition/Runtime/Core/Debugging/FrameSettingsFieldAttribute.cs b/com.unity.render-pipelines.high-definition/Runtime/Core/Debugging/FrameSettingsFieldAttribute.cs index 9d5830a221a..0757126ba9f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Core/Debugging/FrameSettingsFieldAttribute.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Core/Debugging/FrameSettingsFieldAttribute.cs @@ -1,5 +1,7 @@ using System; using System.Text; +using System.Collections.Generic; +using System.Reflection; namespace UnityEngine.Rendering.HighDefinition { @@ -42,6 +44,20 @@ public enum DisplayType { BoolAsCheckbox, BoolAsEnumPopup, Others } static int autoOrder = 0; + private static Dictionary s_FrameSettingsAutoNames = new Dictionary(); + + static FrameSettingsFieldAttribute() + { + Type type = typeof(FrameSettingsField); + foreach (string enumName in Enum.GetNames(type)) + { + if (type.GetField(enumName).GetCustomAttribute() != null) + continue; + + s_FrameSettingsAutoNames.Add((FrameSettingsField)Enum.Parse(type, enumName), enumName.CamelToPascalCaseWithSpace()); + } + } + /// Attribute contenaing generation info for inspector and DebugMenu /// Group index contening this element. /// [Optional] Helper to name the label as the enum entry given. Alternatively, use displayedName. @@ -65,7 +81,7 @@ public FrameSettingsFieldAttribute( int customOrderInGroup = -1) { if (string.IsNullOrEmpty(displayedName)) - displayedName = autoName.ToString().CamelToPascalCaseWithSpace(); + displayedName = s_FrameSettingsAutoNames[autoName]; // Editor and Runtime debug menu this.group = group; diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs index 1ae48c7d1e4..3bd479c4499 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs @@ -149,62 +149,63 @@ public enum FrameSettingsField /// When enabled, HDRP processes a refraction render pass for Cameras using these Frame Settings. This add a resolve of ColorBuffer after the drawing of opaque materials to be use for Refraction effect during transparent pass. [FrameSettingsField(0, autoName: Refraction, customOrderInGroup: 15, tooltip: "When enabled, HDRP processes a refraction render pass for Cameras using these Frame Settings. This add a resolve of ColorBuffer after the drawing of opaque materials to be use for Refraction effect during transparent pass.")] Refraction = 13, + //NOTE: Obsoletes must precede the proper enums, otherwise the compiler occludes them. /// When enabled, HDRP processes a refraction render pass for Cameras using these Frame Settings. This add a resolve of ColorBuffer after the drawing of opaque materials to be use for Refraction effect during transparent pass. [Obsolete] RoughRefraction = 13, /// When enabled, HDRP processes a distortion render pass for Cameras using these Frame Settings. - [FrameSettingsField(0, autoName: Distortion, tooltip: "When enabled, HDRP processes a distortion render pass for Cameras using these Frame Settings (Depends on \"Distortion\" in current HDRP Asset).")] + [FrameSettingsField(0, autoName: Distortion, customOrderInGroup: 16, tooltip: "When enabled, HDRP processes a distortion render pass for Cameras using these Frame Settings (Depends on \"Distortion\" in current HDRP Asset).")] Distortion = 14, /// When enabled, HDRP processes a distortion render pass for Cameras using these Frame Settings. - [FrameSettingsField(0, autoName: RoughDistortion, customOrderInGroup: 16, positiveDependencies: new[] { Distortion }, tooltip: "When enabled, HDRP processes a distortion render pass for Cameras using these Frame Settings (Depends on \"Distortion\" in current HDRP Asset).")] + [FrameSettingsField(0, autoName: RoughDistortion, customOrderInGroup: 17, positiveDependencies: new[] { Distortion }, tooltip: "When enabled, HDRP processes a distortion render pass for Cameras using these Frame Settings (Depends on \"Distortion\" in current HDRP Asset).")] RoughDistortion = 67, /// When enabled, HDRP processes a post-processing render pass for Cameras using these Frame Settings. - [FrameSettingsField(0, displayedName: "Post-process", customOrderInGroup: 17, tooltip: "When enabled, HDRP processes a post-processing render pass for Cameras using these Frame Settings.")] + [FrameSettingsField(0, displayedName: "Post-process", customOrderInGroup: 18, tooltip: "When enabled, HDRP processes a post-processing render pass for Cameras using these Frame Settings.")] Postprocess = 15, /// When enabled, HDRP render user written post processes. - [FrameSettingsField(0, displayedName: "Custom Post-process", positiveDependencies: new[] { Postprocess }, customOrderInGroup: 17, tooltip: "When enabled, HDRP render user written post processes.")] + [FrameSettingsField(0, displayedName: "Custom Post-process", positiveDependencies: new[] { Postprocess }, customOrderInGroup: 19, tooltip: "When enabled, HDRP render user written post processes.")] CustomPostProcess = 39, /// When enabled, HDRP replace NaN values with black pixels for Cameras using these Frame Settings. - [FrameSettingsField(0, displayedName: "Stop NaN", positiveDependencies: new[] { Postprocess }, customOrderInGroup: 17, tooltip: "When enabled, HDRP replace NaN values with black pixels for Cameras using these Frame Settings.")] + [FrameSettingsField(0, displayedName: "Stop NaN", positiveDependencies: new[] { Postprocess }, customOrderInGroup: 19, tooltip: "When enabled, HDRP replace NaN values with black pixels for Cameras using these Frame Settings.")] StopNaN = 80, /// When enabled, HDRP adds depth of field to Cameras affected by a Volume containing the Depth Of Field override. - [FrameSettingsField(0, autoName: DepthOfField, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 17, tooltip: "When enabled, HDRP adds depth of field to Cameras affected by a Volume containing the Depth Of Field override.")] + [FrameSettingsField(0, autoName: DepthOfField, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 19, tooltip: "When enabled, HDRP adds depth of field to Cameras affected by a Volume containing the Depth Of Field override.")] DepthOfField = 81, /// When enabled, HDRP adds motion blur to Cameras affected by a Volume containing the Blur override. - [FrameSettingsField(0, autoName: MotionBlur, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 17, tooltip: "When enabled, HDRP adds motion blur to Cameras affected by a Volume containing the Blur override.")] + [FrameSettingsField(0, autoName: MotionBlur, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 19, tooltip: "When enabled, HDRP adds motion blur to Cameras affected by a Volume containing the Blur override.")] MotionBlur = 82, /// When enabled, HDRP adds panini projection to Cameras affected by a Volume containing the Panini Projection override. - [FrameSettingsField(0, autoName: PaniniProjection, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 17, tooltip: "When enabled, HDRP adds panini projection to Cameras affected by a Volume containing the Panini Projection override.")] + [FrameSettingsField(0, autoName: PaniniProjection, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 19, tooltip: "When enabled, HDRP adds panini projection to Cameras affected by a Volume containing the Panini Projection override.")] PaniniProjection = 83, /// When enabled, HDRP adds bloom to Cameras affected by a Volume containing the Bloom override. - [FrameSettingsField(0, autoName: Bloom, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 17, tooltip: "When enabled, HDRP adds bloom to Cameras affected by a Volume containing the Bloom override.")] + [FrameSettingsField(0, autoName: Bloom, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 19, tooltip: "When enabled, HDRP adds bloom to Cameras affected by a Volume containing the Bloom override.")] Bloom = 84, /// When enabled, HDRP adds lens distortion to Cameras affected by a Volume containing the Lens Distortion override. - [FrameSettingsField(0, autoName: LensDistortion, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 17, tooltip: "When enabled, HDRP adds lens distortion to Cameras affected by a Volume containing the Lens Distortion override.")] + [FrameSettingsField(0, autoName: LensDistortion, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 19, tooltip: "When enabled, HDRP adds lens distortion to Cameras affected by a Volume containing the Lens Distortion override.")] LensDistortion = 85, /// When enabled, HDRP adds chromatic aberration to Cameras affected by a Volume containing the Chromatic Aberration override. - [FrameSettingsField(0, autoName: ChromaticAberration, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 17, tooltip: "When enabled, HDRP adds chromatic aberration to Cameras affected by a Volume containing the Chromatic Aberration override.")] + [FrameSettingsField(0, autoName: ChromaticAberration, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 19, tooltip: "When enabled, HDRP adds chromatic aberration to Cameras affected by a Volume containing the Chromatic Aberration override.")] ChromaticAberration = 86, /// When enabled, HDRP adds vignette to Cameras affected by a Volume containing the Vignette override. - [FrameSettingsField(0, autoName: Vignette, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 17, tooltip: "When enabled, HDRP adds vignette to Cameras affected by a Volume containing the Vignette override.")] + [FrameSettingsField(0, autoName: Vignette, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 19, tooltip: "When enabled, HDRP adds vignette to Cameras affected by a Volume containing the Vignette override.")] Vignette = 87, /// When enabled, HDRP processes color grading for Cameras using these Frame Settings. - [FrameSettingsField(0, autoName: ColorGrading, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 17, tooltip: "When enabled, HDRP processes color grading for Cameras using these Frame Settings.")] + [FrameSettingsField(0, autoName: ColorGrading, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 19, tooltip: "When enabled, HDRP processes color grading for Cameras using these Frame Settings.")] ColorGrading = 88, /// When enabled, HDRP processes tonemapping for Cameras using these Frame Settings. - [FrameSettingsField(0, autoName: Tonemapping, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 17, tooltip: "When enabled, HDRP processes tonemapping for Cameras using these Frame Settings.")] + [FrameSettingsField(0, autoName: Tonemapping, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 19, tooltip: "When enabled, HDRP processes tonemapping for Cameras using these Frame Settings.")] Tonemapping = 93, /// When enabled, HDRP adds film grain to Cameras affected by a Volume containing the Film Grain override. - [FrameSettingsField(0, autoName: FilmGrain, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 18, tooltip: "When enabled, HDRP adds film grain to Cameras affected by a Volume containing the Film Grain override.")] + [FrameSettingsField(0, autoName: FilmGrain, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 19, tooltip: "When enabled, HDRP adds film grain to Cameras affected by a Volume containing the Film Grain override.")] FilmGrain = 89, /// When enabled, HDRP processes dithering for Cameras using these Frame Settings. - [FrameSettingsField(0, autoName: Dithering, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 18, tooltip: "When enabled, HDRP processes dithering for Cameras using these Frame Settings.")] + [FrameSettingsField(0, autoName: Dithering, positiveDependencies: new[] { Postprocess }, customOrderInGroup: 19, tooltip: "When enabled, HDRP processes dithering for Cameras using these Frame Settings.")] Dithering = 90, /// When enabled, HDRP processes anti-aliasing for camera using these Frame Settings. - [FrameSettingsField(0, displayedName: "Anti-aliasing", positiveDependencies: new[] { Postprocess }, customOrderInGroup: 18, tooltip: "When enabled, HDRP processes anti-aliasing for camera using these Frame Settings.")] + [FrameSettingsField(0, displayedName: "Anti-aliasing", positiveDependencies: new[] { Postprocess }, customOrderInGroup: 19, tooltip: "When enabled, HDRP processes anti-aliasing for camera using these Frame Settings.")] Antialiasing = 91, /// When enabled, HDRP processes a post-processing render pass for Cameras using these Frame Settings. - [FrameSettingsField(0, displayedName: "After Post-process", customOrderInGroup: 19, tooltip: "When enabled, HDRP processes a post-processing render pass for Cameras using these Frame Settings.")] + [FrameSettingsField(0, displayedName: "After Post-process", customOrderInGroup: 20, tooltip: "When enabled, HDRP processes a post-processing render pass for Cameras using these Frame Settings.")] AfterPostprocess = 17, /// When enabled, Cameras that don't use TAA process a depth test for Materials in the AfterPostProcess rendering pass. [FrameSettingsField(0, displayedName: "Depth Test", positiveDependencies: new[] { AfterPostprocess }, customOrderInGroup: 20, tooltip: "When enabled, Cameras that don't use TAA process a depth test for Materials in the AfterPostProcess rendering pass.")] From 6b90f2d4ca47c67373d84d35d105668b7ce0571a Mon Sep 17 00:00:00 2001 From: Kleber Garcia Date: Wed, 24 Feb 2021 09:09:04 -0500 Subject: [PATCH 2/3] Moving reflection call to its own utility function, and caching frame settings names. --- .../Settings/OverridableFrameSettingsArea.cs | 8 +++--- .../Debugging/FrameSettingsFieldAttribute.cs | 27 +++++++++++++------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/OverridableFrameSettingsArea.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/OverridableFrameSettingsArea.cs index 454c031f8b3..5d4fe2acc5e 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/OverridableFrameSettingsArea.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/OverridableFrameSettingsArea.cs @@ -26,13 +26,11 @@ static OverridableFrameSettingsArea() { attributes = new Dictionary(); attributesGroup = new Dictionary>>(); + Dictionary frameSettingsEnumNameMap = FrameSettingsFieldAttribute.GetEnumNameMap(); Type type = typeof(FrameSettingsField); - foreach (string enumName in Enum.GetNames(type)) + foreach (FrameSettingsField enumVal in frameSettingsEnumNameMap.Keys) { - if (type.GetField(enumName).GetCustomAttribute() != null) - continue; - - attributes[(FrameSettingsField)Enum.Parse(type, enumName)] = type.GetField(enumName).GetCustomAttribute(); + attributes[enumVal] = type.GetField(frameSettingsEnumNameMap[enumVal]).GetCustomAttribute(); } frameSettingsKeywords = attributes diff --git a/com.unity.render-pipelines.high-definition/Runtime/Core/Debugging/FrameSettingsFieldAttribute.cs b/com.unity.render-pipelines.high-definition/Runtime/Core/Debugging/FrameSettingsFieldAttribute.cs index 0757126ba9f..e18060991da 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Core/Debugging/FrameSettingsFieldAttribute.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Core/Debugging/FrameSettingsFieldAttribute.cs @@ -44,18 +44,29 @@ public enum DisplayType { BoolAsCheckbox, BoolAsEnumPopup, Others } static int autoOrder = 0; - private static Dictionary s_FrameSettingsAutoNames = new Dictionary(); + private static Dictionary s_FrameSettingsEnumNameMap = null; - static FrameSettingsFieldAttribute() + public static Dictionary GetEnumNameMap() { - Type type = typeof(FrameSettingsField); - foreach (string enumName in Enum.GetNames(type)) + if (s_FrameSettingsEnumNameMap == null) { - if (type.GetField(enumName).GetCustomAttribute() != null) - continue; + s_FrameSettingsEnumNameMap = new Dictionary(); + Type type = typeof(FrameSettingsField); + foreach (string enumName in Enum.GetNames(type)) + { + if (type.GetField(enumName).GetCustomAttribute() != null) + continue; - s_FrameSettingsAutoNames.Add((FrameSettingsField)Enum.Parse(type, enumName), enumName.CamelToPascalCaseWithSpace()); + s_FrameSettingsEnumNameMap.Add((FrameSettingsField)Enum.Parse(type, enumName), enumName); + } } + + return s_FrameSettingsEnumNameMap; + } + + static FrameSettingsFieldAttribute() + { + GetEnumNameMap();//build the enum name map. } /// Attribute contenaing generation info for inspector and DebugMenu @@ -81,7 +92,7 @@ public FrameSettingsFieldAttribute( int customOrderInGroup = -1) { if (string.IsNullOrEmpty(displayedName)) - displayedName = s_FrameSettingsAutoNames[autoName]; + displayedName = s_FrameSettingsEnumNameMap[autoName].CamelToPascalCaseWithSpace(); // Editor and Runtime debug menu this.group = group; From 855a977ed13f4aac850aa9068036db7f484c8aad Mon Sep 17 00:00:00 2001 From: Kleber Garcia Date: Wed, 24 Feb 2021 19:48:53 -0500 Subject: [PATCH 3/3] Adding changelog changes. --- 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 3c11cecc548..e3da0783126 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -49,6 +49,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed performance issue with ShaderGraph and Alpha Test - Fixed error when increasing the maximum planar reflection limit (case 1306530). - Fixed alpha output in debug view and AOVs when using shadow matte (case 1311830). +- Fixed multiple HDRP Frame Settings panel issues: missing "Refraction" Frame Setting. Fixing ordering of Rough Distortion, it should now be under the Distortion setting. ### Changed - Changed Window/Render Pipeline/HD Render Pipeline Wizard to Window/Rendering/HDRP Wizard