diff --git a/com.unity.render-pipelines.core/CHANGELOG.md b/com.unity.render-pipelines.core/CHANGELOG.md index d045ee7c356..e5fa5b1ddcf 100644 --- a/com.unity.render-pipelines.core/CHANGELOG.md +++ b/com.unity.render-pipelines.core/CHANGELOG.md @@ -22,11 +22,13 @@ The version number for this package has increased due to a version update of a r ### Added - New `IVolumeDebugSettings` interface and `VolumeDebugSettings` class that stores the information for the Volumes Debug Panel. - Added AMD FidelityFX shaders which were originally in HDRP -- Added support for high performant unsafe (uint only) Radix, Merge and Insertion sort algorithms on CoreUnsafeUtils. +- Added warning on Volumes not supported by the current pipeline. +- Added option to hide not overrided properties on Volume Components. ### Fixed - Fixed black pixel issue in AMD FidelityFX RCAS implementation - Fixed a critical issue on android devices & lens flares. Accidentally creating a 16 bit texture was causing gpus not supporting them to fail. +- Fixed the processing of volumes that are not supported to the current pipeline. ## [12.0.0] - 2021-01-11 diff --git a/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentEditor.cs b/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentEditor.cs index 42c2bee8539..1e227c1977e 100644 --- a/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentEditor.cs +++ b/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentEditor.cs @@ -78,11 +78,12 @@ public class VolumeComponentEditor { class Styles { - public static GUIContent overrideSettingText { get; } = EditorGUIUtility.TrTextContent("", "Override this setting for this volume."); - public static GUIContent allText { get; } = EditorGUIUtility.TrTextContent("ALL", "Toggle all overrides on. To maximize performances you should only toggle overrides that you actually need."); - public static GUIContent noneText { get; } = EditorGUIUtility.TrTextContent("NONE", "Toggle all overrides off."); + public readonly static GUIContent overrideSettingText = EditorGUIUtility.TrTextContent("", "Override this setting for this volume."); + public readonly static GUIContent allText = EditorGUIUtility.TrTextContent("ALL", "Toggle all overrides on. To maximize performances you should only toggle overrides that you actually need."); + public readonly static GUIContent noneText = EditorGUIUtility.TrTextContent("NONE", "Toggle all overrides off."); - public static string toggleAllText { get; } = L10n.Tr("Toggle All"); + public static readonly string toggleAllText = L10n.Tr("Toggle All"); + public static readonly string unsuportedFeature = L10n.Tr("This feature is not supported by the current active render pipeline"); public const int overrideCheckboxWidth = 14; public const int overrideCheckboxOffset = 9; @@ -150,6 +151,27 @@ public bool showAdditionalProperties } } + EditorPrefBool m_ShowOnlyOverriddenParameters; + internal void SetShowOnlyOverridedParameters(bool value) + { + m_ShowOnlyOverriddenParameters.value = value; + } + + internal void InitShowOnlyOverridedParametersPreference() + { + string key = $"UI_Show_Only_Overridden_Parameters_{GetType()}"; + m_ShowOnlyOverriddenParameters = new EditorPrefBool(key); + } + + /// + /// Set to true to show only the parameters that are overrided + /// + public bool showOnlyOverriddenParameters + { + get => m_ShowOnlyOverriddenParameters.value; + set => SetShowOnlyOverridedParameters(value); + } + /// /// Start a scope for additional properties. /// This will handle the highlight of the background when toggled on and off. @@ -247,9 +269,10 @@ internal void Init(VolumeComponent target, Editor inspector) this.target = target; m_Inspector = inspector; serializedObject = new SerializedObject(target); - activeProperty = serializedObject.FindProperty("active"); + activeProperty = serializedObject.FindProperty("m_Active"); InitAdditionalPropertiesPreference(); + InitShowOnlyOverridedParametersPreference(); m_AdditionalPropertiesAnimation = new AnimFloat(0, Repaint) { @@ -337,8 +360,18 @@ internal void OnInternalInspectorGUI() serializedObject.Update(); using (new EditorGUILayout.VerticalScope()) { - TopRowFields(); - OnInspectorGUI(); + if (!target.supportedOnCurrentPipeline) + { + EditorGUILayout.HelpBox(Styles.unsuportedFeature, MessageType.Warning, true); + } + else + { + TopRowFields(); + } + + using (new EditorGUI.DisabledScope(!target.supportedOnCurrentPipeline)) + OnInspectorGUI(); + EditorGUILayout.Space(); } serializedObject.ApplyModifiedProperties(); @@ -557,6 +590,9 @@ protected bool PropertyField(SerializedDataParameter property, GUIContent title) /// A custom label and/or tooltip. private bool DrawPropertyField(SerializedDataParameter property, GUIContent title) { + if (!property.overrideState.boolValue && showOnlyOverriddenParameters) + return false; + using (var scope = new OverridablePropertyScope(property, title, this)) { if (!scope.displayed) @@ -628,6 +664,9 @@ private bool DrawEmbeddedField(SerializedDataParameter property, GUIContent titl /// The property to draw the override checkbox for protected void DrawOverrideCheckbox(SerializedDataParameter property) { + if (!target.supportedOnCurrentPipeline) + return; + // Create a rect the height + vspacing of the property that is being overriden float height = EditorGUI.GetPropertyHeight(property.value) + EditorGUIUtility.standardVerticalSpacing; var overrideRect = GUILayoutUtility.GetRect(Styles.allText, CoreEditorStyles.miniLabelButton, GUILayout.Height(height), GUILayout.Width(Styles.overrideCheckboxWidth + Styles.overrideCheckboxOffset), GUILayout.ExpandWidth(false)); diff --git a/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs b/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs index 209aee6e6b5..87a6dfee951 100644 --- a/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs +++ b/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs @@ -45,6 +45,11 @@ namespace UnityEditor.Rendering /// public sealed class VolumeComponentListEditor { + class Styles + { + public static readonly string noSRPInUse = L10n.Tr("No SRP in Use"); + } + /// /// A direct reference to the this editor displays. /// @@ -89,6 +94,9 @@ public void Init(VolumeProfile asset, SerializedObject serializedObject) Assert.IsNotNull(asset); Assert.IsNotNull(serializedObject); + // Make sure that the volumes are being updated + asset.UpdateIsSupportedOnCurrentPipeline(); + this.asset = asset; m_SerializedObject = serializedObject; m_ComponentsProperty = serializedObject.Find((VolumeProfile x) => x.components); @@ -246,7 +254,7 @@ public void OnGUI() if (displayContent) { - using (new EditorGUI.DisabledScope(!editor.activeProperty.boolValue)) + using (new EditorGUI.DisabledScope(!editor.activeProperty.boolValue && !editor.target.supportedOnCurrentPipeline)) editor.OnInternalInspectorGUI(); } } @@ -308,7 +316,8 @@ void OnContextClick(Vector2 position, VolumeComponentEditor targetEditor, int id menu.AddItem(EditorGUIUtility.TrTextContent("Show Additional Properties"), targetEditor.showAdditionalProperties, () => targetEditor.showAdditionalProperties ^= true); else menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Show Additional Properties")); - menu.AddItem(EditorGUIUtility.TrTextContent("Show All Additional Properties..."), false, () => CoreRenderPipelinePreferences.Open()); + menu.AddItem(EditorGUIUtility.TrTextContent("Show Only Overridden Parameters"), targetEditor.showOnlyOverriddenParameters, () => targetEditor.showOnlyOverriddenParameters = !targetEditor.showOnlyOverriddenParameters); + menu.AddItem(EditorGUIUtility.TrTextContent("Open Core Render Pipeline Preferences..."), false, () => CoreRenderPipelinePreferences.Open()); menu.AddSeparator(string.Empty); menu.AddItem(EditorGUIUtility.TrTextContent("Copy Settings"), false, () => CopySettings(targetComponent)); diff --git a/com.unity.render-pipelines.core/Editor/Volume/VolumeEditor.cs b/com.unity.render-pipelines.core/Editor/Volume/VolumeEditor.cs index 2e7e88df9ac..92a4d16ba23 100644 --- a/com.unity.render-pipelines.core/Editor/Volume/VolumeEditor.cs +++ b/com.unity.render-pipelines.core/Editor/Volume/VolumeEditor.cs @@ -118,6 +118,13 @@ private static void EnableAllOverrides(MenuCommand command) public override void OnInspectorGUI() { + var currentPipeline = RenderPipelineManager.currentPipeline; + if (currentPipeline == null) + { + EditorGUILayout.HelpBox("No SRP in use", MessageType.Warning, true); + return; + } + serializedObject.Update(); Rect lineRect = EditorGUILayout.GetControlRect(); diff --git a/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs b/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs index adf1a8eeae3..f36f32dc4bf 100644 --- a/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs +++ b/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs @@ -3,6 +3,7 @@ using System.Collections.ObjectModel; using System.Reflection; using System.Linq; +using UnityEngine.Serialization; namespace UnityEngine.Rendering { @@ -109,11 +110,21 @@ public Indent(int relativeAmount = 1) => this.relativeAmount = relativeAmount; } + [SerializeField] + [FormerlySerializedAs("active")] + private bool m_Active = true; + + internal bool supportedOnCurrentPipeline { get; set; } = true; + /// /// The active state of the set of parameters defined in this class. You can use this to /// quickly turn on or off all the overrides at once. /// - public bool active = true; + public bool active + { + get => m_Active && supportedOnCurrentPipeline; + set => m_Active = value; + } /// /// The name displayed in the component header. If you do not set a name, Unity generates one from diff --git a/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs b/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs index 30ec7ce4e28..3946f7b4646 100644 --- a/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs +++ b/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Linq; +using System.Reflection; using UnityEngine.Assertions; namespace UnityEngine.Rendering @@ -30,6 +32,40 @@ void OnEnable() // harmless and happens because Unity does a redraw of the editor (and thus the current // frame) before the recompilation step. components.RemoveAll(x => x == null); + + // Subscribe to the changes performed on the current pipeline to know which Volume Components are supported on the current pipeline + RenderPipelineManager.activeRenderPipelineTypeChanged += UpdateIsSupportedOnCurrentPipeline; + UpdateIsSupportedOnCurrentPipeline(); + } + + private void OnDisable() + { + RenderPipelineManager.activeRenderPipelineTypeChanged -= UpdateIsSupportedOnCurrentPipeline; + } + + internal void UpdateIsSupportedOnCurrentPipeline() + { + var currentPipeline = RenderPipelineManager.currentPipeline; + if (currentPipeline != null) + { + var currentPipelineType = currentPipeline.GetType(); + foreach (var component in components) + { + SetIsSupportedOnPipeline(component, currentPipelineType); + } + } + } + + void SetIsSupportedOnPipeline(VolumeComponent component, Type renderPipelineType) + { + bool supportedOnCurrentPipeline = true; + + // Get the supported pipelines for the volume component + if (component.GetType().GetCustomAttribute(typeof(VolumeComponentMenuForRenderPipeline), false) is VolumeComponentMenuForRenderPipeline supportedOn) + { + supportedOnCurrentPipeline = supportedOn.pipelineTypes.Contains(renderPipelineType); + } + component.supportedOnCurrentPipeline = supportedOnCurrentPipeline; } /// @@ -80,7 +116,16 @@ public VolumeComponent Add(Type type, bool overrides = false) component.name = type.Name; #endif component.SetAllOverridesTo(overrides); + + var currentPipeline = RenderPipelineManager.currentPipeline; + if (currentPipeline != null) + { + var currentPipelineType = currentPipeline.GetType(); + SetIsSupportedOnPipeline(component, currentPipeline.GetType()); + } + components.Add(component); + isDirty = true; return component; } diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VolumeComponentWithQualityEditor.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VolumeComponentWithQualityEditor.cs index b908537351e..3ff496a5f0d 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VolumeComponentWithQualityEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/VolumeComponentWithQualityEditor.cs @@ -169,8 +169,7 @@ public override void OnInspectorGUI() // If we have switched to custom quality from a preset, then load the last custom quality settings the user has used in this volume if (prevQualityLevel != k_CustomQuality) { - QualitySettingsBlob history = null; - s_CustomSettingsHistory.TryGetValue(serializedObject.targetObject, out history); + s_CustomSettingsHistory.TryGetValue(serializedObject.targetObject, out QualitySettingsBlob history); if (history != null) { LoadSettingsFromObject(history); @@ -180,14 +179,12 @@ public override void OnInspectorGUI() else { // If we are going to use a quality preset, then load the preset values so they are reflected in the UI - var pipeline = (HDRenderPipeline)RenderPipelineManager.currentPipeline; - if (pipeline != null) + if (RenderPipelineManager.currentPipeline is HDRenderPipeline pipeline) { // If we switch from a custom quality level, then save these values so we can re-use them if teh user switches back if (prevQualityLevel == k_CustomQuality) { - QualitySettingsBlob history = null; - s_CustomSettingsHistory.TryGetValue(serializedObject.targetObject, out history); + s_CustomSettingsHistory.TryGetValue(serializedObject.targetObject, out QualitySettingsBlob history); if (history != null) { SaveCustomQualitySettingsAsObject(history);