diff --git a/Packages/com.unity.render-pipelines.core/Documentation~/Images/customsettings-addsetting.png b/Packages/com.unity.render-pipelines.core/Documentation~/Images/customsettings-addsetting.png new file mode 100644 index 00000000000..8c887e4c16f Binary files /dev/null and b/Packages/com.unity.render-pipelines.core/Documentation~/Images/customsettings-addsetting.png differ diff --git a/Packages/com.unity.render-pipelines.core/Documentation~/Images/customsettings-settingsgroup.png b/Packages/com.unity.render-pipelines.core/Documentation~/Images/customsettings-settingsgroup.png new file mode 100644 index 00000000000..f014e83f122 Binary files /dev/null and b/Packages/com.unity.render-pipelines.core/Documentation~/Images/customsettings-settingsgroup.png differ diff --git a/Packages/com.unity.render-pipelines.core/Documentation~/TableOfContents.md b/Packages/com.unity.render-pipelines.core/Documentation~/TableOfContents.md index 510bc01d3eb..6adc3f35232 100644 --- a/Packages/com.unity.render-pipelines.core/Documentation~/TableOfContents.md +++ b/Packages/com.unity.render-pipelines.core/Documentation~/TableOfContents.md @@ -20,11 +20,13 @@ * [RTHandle fundamentals](rthandle-system-fundamentals.md) * [Using the RTHandle system](rthandle-system-using.md) * [Custom Material Inspector](custom-material-inspector.md) -* [Custom settings](settings.md) +* [Custom graphics settings](settings.md) * [Adding properties in the menu](adding-properties.md) - * [Add custom graphics settings](add-custom-graphics-settings.md) + * [Add a settings group](add-custom-graphics-settings.md) + * [Add a setting](add-custom-graphics-setting.md) + * [Customize the UI of a setting](customize-ui-for-a-setting.md) * [Get custom graphics settings](get-custom-graphics-settings.md) - * [Include or excude a setting in your build](choose-whether-unity-includes-a-graphics-setting-in-your-build.md) + * [Include or exclude a setting in your build](choose-whether-unity-includes-a-graphics-setting-in-your-build.md) * [Shaders](shaders.md) * [Use shader methods from the SRP Core shader library](built-in-shader-methods.md) * [Synchronizing shader code and C#](generating-shader-includes.md) diff --git a/Packages/com.unity.render-pipelines.core/Documentation~/add-custom-graphics-setting.md b/Packages/com.unity.render-pipelines.core/Documentation~/add-custom-graphics-setting.md new file mode 100644 index 00000000000..d3a57390314 --- /dev/null +++ b/Packages/com.unity.render-pipelines.core/Documentation~/add-custom-graphics-setting.md @@ -0,0 +1,60 @@ +# Add a setting + +Add a simple property or a reference property to a [custom graphics settings group](add-custom-graphics-settings.md). You can change the values of the setting in the Unity Editor while you're editing your project. + +Unity serializes the graphics settings you add. For more information, refer to [Script serialization](xref:um-script-serialization). + +**Note:** The value of a custom setting is static in a built project. You can't change the setting at runtime. + +## Add a simple property + +To add a simple property, add a field to your `IRenderPipelineGraphicsSettings` class using the `[SerializeField]` attribute. For example: + +```c# +using System; +using UnityEngine; +using UnityEngine.Rendering; +using UnityEngine.Rendering.Universal; + +[Serializable] +[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))] + +// Create a new settings group by implementing the IRenderPipelineGraphicsSettings interface +public class MySettings : IRenderPipelineGraphicsSettings +{ + // Add a private field for the version property + int internalVersion = 1; + + // Implement the public version property + public int version => internalVersion; + + // Add a float setting + [SerializeField] + private float mySetting = 1.0f; + + // Add a Material reference property + [SerializeField] + public Material myMaterial; +} +``` +![](Images/customsettings-addsetting.png)
+The **Edit** > **Project Settings** > **Graphics** window with the new custom setting from the example script. + +## Set the default asset for a reference property + +To set a default asset for a [reference property](xref:um-editing-value-properties#references), for example a material, add a [`[ResourcePath]`](https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Rendering.ResourcePathAttribute.html) attribute. For example: + +```c# +public class MySettings: IRenderPipelineGraphicsSettings +{ + ... + [SerializeField] + [ResourcePath('path-to-default-file')] + public Material myMaterial; +} +``` + +## Additional resources + +- [SerializeField](xref:UnityEngine.SerializeField) +- [Reference properties](xref:EditingValueProperties#references) diff --git a/Packages/com.unity.render-pipelines.core/Documentation~/add-custom-graphics-settings.md b/Packages/com.unity.render-pipelines.core/Documentation~/add-custom-graphics-settings.md index 7b646446f42..1365a8648f4 100644 --- a/Packages/com.unity.render-pipelines.core/Documentation~/add-custom-graphics-settings.md +++ b/Packages/com.unity.render-pipelines.core/Documentation~/add-custom-graphics-settings.md @@ -1,24 +1,26 @@ -# Add custom graphics settings +# Add a settings group -You can add custom graphics settings to the **Edit** > **Project Settings** > **Graphics** window, then use the values of the settings to customize your build. +To add a custom graphics settings group to a Scriptable Render Pipeline, implement the `IRenderPipelineGraphicsSettings` interface. -You can change the values of settings while you're editing your project. Unity makes the values static when it builds your project, so you can't change them at runtime. +Follow these steps: -## Add a setting +1. Create a class that implements the `IRenderPipelineGraphicsSettings` interface, then add a `[Serializable]` attribute. -To add a setting, follow these steps: - -1. Create a class that implements the `IRenderPipelineGraphicsSettings` interface, and add a `[Serializable]` attribute. This becomes a new settings group in the **Graphics** settings window. 2. To set which render pipeline the setting applies to, add a `[SupportedOnRenderPipeline]` attribute and pass in a `RenderPipelineAsset` type. -3. Add a property. This becomes a setting. -4. Implement the `version` field and set it to `0`. Unity doesn't currently use the `version` field, but you must implement it. -For example, the following script adds a setting called **My Value** in a settings group called **My Settings**, in the graphics settings for the Universal Render Pipeline (URP). + **Note:** If you don't add a `[SupportedOnRenderPipeline]` attribute, the setting applies to any Scriptable Render Pipeline. However each Scriptable Render Pipeline stores its own value for the setting. + +3. Implement the `version` property. Unity doesn't currently use the `version` property, but you must implement it. + +Unity adds the new settings group to the **Edit** > **Project Settings** > **Graphics** window. + +For example, the following script adds a settings group called **My Settings** in the **Graphics** settings window of the Universal Render Pipeline (URP). ```c# +using System; using UnityEngine; using UnityEngine.Rendering; -using System; +using UnityEngine.Rendering.Universal; [Serializable] [SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))] @@ -26,67 +28,30 @@ using System; // Create a new settings group by implementing the IRenderPipelineGraphicsSettings interface public class MySettings : IRenderPipelineGraphicsSettings { - // Implement the version field - public int version => 0; + // Add a private field for the version property + int internalVersion = 1; + + // Implement the public version property + public int version => internalVersion; - // Create a new setting and set its default value to 100. - public int myValue = 100; } ``` -## Add a reference property - -[Reference properties](https://docs.unity3d.com/2023.3/Documentation/Manual/EditingValueProperties.html#references) take compatible project assets or GameObjects in the scene as inputs. +![](Images/customsettings-settingsgroup.png)
+The **Edit** > **Project Settings** > **Graphics** window with the new custom settings group from the example script. -To add a reference property, follow these steps: +## Change the display order of settings groups -1. Create a class that implements the `IRenderPipelineResources` interface. This becomes a new settings group in the Graphics Settings window. -2. Add a property. This becomes a reference property. -3. Implement the `version` field and set it to `0`. Unity doesn't currently use the `version` field, but you must implement it. - -For example, the following script adds a reference property called **My Material** that references a material. +To change where a settings group appears, use the `[UnityEngine.Categorization.CategoryInfo]` attribute. For example, the following code gives the settings group the name **My Settings** and moves the group to the top of the graphics settings window. ```c# -using UnityEngine; -using UnityEngine.Rendering; -using System; - -[Serializable] -[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))] - -// Create a new reference property group by implementing the IRenderPipelineResources interface -public class MySettings: IRenderPipelineResources +[UnityEngine.Categorization.CategoryInfo(Name = "My Settings", Order = 0)] +public class MySettings : IRenderPipelineGraphicsSettings { - // Implement the version field - public int version => 0; - - // Create a new reference property that references a material - [SerializeField] public Material myMaterial; + ... } ``` -To set a default asset, use a [`[ResourcePath]`](https://docs.unity3d.com/2023.3/Documentation/ScriptReference/Rendering.ResourcePathAttribute.html) attribute above the reference property. For example, in the example, add the following line above `public Material myMaterial`. - -```c# -[ResourcePath('path-to-default-file')] -``` - -## Change the name and layout of a settings group - -To change the name of a settings group in the **Graphics** settings window, follow these steps: - -1. Add `using System.ComponentModel` to your script. -2. Add a `[Category]` attribute to your script. For example, `[Category("My Category")]`. - -You can also use the [PropertyDrawer](https://docs.unity3d.com/ScriptReference/PropertyDrawer.html) API to further customize the layout of custom settings. - -## Set which render pipeline a setting applies to - -To set which render pipeline a setting applies to, use the `[SupportedOnRenderPipeline]` attribute and pass in a `RenderPipelineAsset` type. - -For example, if your project uses the Universal Rendering Pipeline (URP) and you want your setting to appear only in the **URP** tab of the **Graphics** settings window, use the following code: - -```c# -[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))] -``` +## Additional resources +- [Add a setting](add-custom-graphics-setting.md) diff --git a/Packages/com.unity.render-pipelines.core/Documentation~/choose-whether-unity-includes-a-graphics-setting-in-your-build.md b/Packages/com.unity.render-pipelines.core/Documentation~/choose-whether-unity-includes-a-graphics-setting-in-your-build.md index 28095123bd3..fe06da1d100 100644 --- a/Packages/com.unity.render-pipelines.core/Documentation~/choose-whether-unity-includes-a-graphics-setting-in-your-build.md +++ b/Packages/com.unity.render-pipelines.core/Documentation~/choose-whether-unity-includes-a-graphics-setting-in-your-build.md @@ -1,31 +1,35 @@ # Include or exclude a setting in your build -By default, Unity doesn't include a setting ("strips" the setting) in your built project. For example, if you create a custom reference property where you set a shader asset, Unity doesn't include that property in your build. +By default, Unity doesn't include a setting ("strips" the setting) in your built project to optimize performance and reduce build size. For example, if you create a custom reference property that points to a shader asset, by default Unity doesn't include that property in your build. -You can choose to include a setting in your build instead. You can then get the value of the setting at runtime. The value is read-only. +You can choose to include a setting in your build instead. The value of the property is read-only at runtime. ## Include a setting in your build -To include a setting in your build by default, set the `IsAvailableInPlayerBuild` property of your [settings class](add-custom-graphics-settings.md) to `true`. +To include a setting in your build by default, set the `IsAvailableInPlayerBuild` property of your [settings group class](add-custom-graphics-settings.md) to `true`. -For example, add the following line: +For example: ```c# -public bool IsAvailableInPlayerBuild => true; +public class MySettings: IRenderPipelineGraphicsSettingsStripper +{ + ... + // Make settings in this class available in your build + public bool IsAvailableInPlayerBuild => true; +} ``` ## Create your own stripping code -You can override the `IsAvailableInPlayerBuild` property by implementing the `IRenderPipelineGraphicsSettingsStripper` interface, and writing code that conditionally strips or keeps the setting. +To conditionally control whether Unity includes or excludes a setting in your build, override the `IsAvailableInPlayerBuild` property by implementing the `IRenderPipelineGraphicsSettingsStripper` interface. Follow these steps: 1. Create a class that implements the `IRenderPipelineGraphicsSettingsStripper` interface, and pass in your [settings class](add-custom-graphics-settings.md). 2. Implement the `active` property. If you set `active` to `false`, the code in the class doesn't run. -3. Implement the `CanRemoveSettings` method with your own code that decides whether to include the setting. -4. In your code, return either `true` or `false` to strip or keep the setting. +3. Implement the `CanRemoveSettings` method with your own code that decides whether to include the setting. Return `true` to strip the setting, or `false` to include the setting. -For example, in the following code, the `CanRemoveSettings` method returns `true` and strips the setting if the value of the setting is larger than 100. +For example: ```c# using UnityEngine; @@ -41,8 +45,8 @@ class SettingsStripper : IRenderPipelineGraphicsSettingsStripper // Implement the CanRemoveSettings method with our own code public bool CanRemoveSettings(MySettings settings) { - // Strip the setting (return true) if the value is larger than 100 - return settings.myValue > 100; + // Strip the setting (return true) if useMyFeature is false + return !settings.useMyFeature; } } ``` @@ -55,8 +59,9 @@ You can check if a setting exists at runtime. A setting might not exist at runti - Unity didn't include the setting in your build. - The current pipeline doesn't support the setting. +- The setting is in an assembly that Unity doesn't include in your build. Refer to [Organizing scripts into assemblies](xref:um-script-compilation-assembly-definition-files) for more information. -Use `TryGetRenderPipelineSettings` to check if the setting exists. `TryGetRenderPipelineSettings` puts the setting in an `out` variable if it exists. Otherwise it returns `false`. +To check if the setting exists, use the `TryGetRenderPipelineSettings` API. `TryGetRenderPipelineSettings` puts the setting in an `out` variable if the setting exists. Otherwise it returns `false`. For example, the following code checks whether a settings group called `MySettings` exists at runtime: @@ -65,3 +70,7 @@ if (GraphicsSettings.TryGetRenderPipelineSettings(out var mySetting) Debug.Log("The setting is in the build and its value is {mySetting.myValue}"); } ``` + +## Additional resources + +- [Organizing scripts into assemblies](xref:um-script-compilation-assembly-definition-files) diff --git a/Packages/com.unity.render-pipelines.core/Documentation~/customize-ui-for-a-setting.md b/Packages/com.unity.render-pipelines.core/Documentation~/customize-ui-for-a-setting.md new file mode 100644 index 00000000000..bf340bb3b79 --- /dev/null +++ b/Packages/com.unity.render-pipelines.core/Documentation~/customize-ui-for-a-setting.md @@ -0,0 +1,77 @@ +# Customize the UI of custom settings + +To change the look of custom settings in the **Graphics** settings window, use the `PropertyDrawer` API. + +Follow these steps: + +1. Create a class that inherits from the [`PropertyDrawer`](xref:UnityEditor.PropertyDrawer) class. +2. Add the `[CustomPropertyDrawer]` attribute to the class, with a reference to your settings class. +3. Override the `PropertyDrawer.CreatePropertyGUI` method, and return a `VisualElement` object that contains the UI elements you want to display. + +The following example creates a custom UI for a `MySettings` class that contains a Boolean and a float field. The Graphics settings window displays the float only when the Boolean field is enabled. + +For more information, refer to [PropertyDrawer](xref:UnityEditor.PropertyDrawer). + +```c# +using UnityEngine; +using UnityEditor; +using UnityEngine.UIElements; + +// Create a custom UI for the properties in the MySettings class +[CustomPropertyDrawer(typeof(MySettings))] +public class MySettingsPropertyDrawer : PropertyDrawer +{ + // Override the CreatePropertyGUI method to define the custom UI + public override VisualElement CreatePropertyGUI(SerializedProperty property) + { + // Create a container to hold the UI elements + var container = new VisualElement(); + + // Find the properties to display + var useProperty = property.FindPropertyRelative("m_UseMyFeature"); + var intensityProperty = property.FindPropertyRelative("m_MyFeatureIntensity"); + + // Create property fields for each property + var usePropertyField = new PropertyField(useProperty); + var intensityPropertyField = new PropertyField(intensityProperty); + + // Enable or disable the intensity field based on the value of m_UseMyFeature + usePropertyField.RegisterValueChangeCallback(evt => + { + intensityPropertyField.SetEnabled(useProperty.boolValue); + }); + + // Add the property fields to the container + container.Add(usePropertyField); + container.Add(intensityPropertyField); + + // Return the container to be displayed in the Graphics settings window + return container; + } +} +``` + +## Customize the More (⋮) menu of a settings group + +To add items to the **More** (⋮) menu of a settings group, follow these steps: + +1. Create a class that implements the [`IRenderPipelineGraphicsSettingsContextMenu`](https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Rendering.IRenderPipelineGraphicsSettingsContextMenu.html) interface. +2. Implement the `PopulateContextMenu` method. +3. To add an item, use the `AddItem` API. + +For example: + +```c# +public class MySettingsContextMenu : IRenderPipelineGraphicsSettingsContextMenu +{ + void IRenderPipelineGraphicsSettingsContextMenu.PopulateContextMenu(MySettings setting, PropertyDrawer _, ref GenericMenu menu) + { + menu.AddItem(new GUIContent("My custom menu item"), false, () => { Debug.Log("Menu item was selected."); }); + } +} +``` + +## Additional resources + +- [PropertyDrawer](xref:UnityEditor.PropertyDrawer) +- [IRenderPipelineGraphicsSettingsContextMenu](https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Rendering.IRenderPipelineGraphicsSettingsContextMenu.html) diff --git a/Packages/com.unity.render-pipelines.core/Documentation~/get-custom-graphics-settings.md b/Packages/com.unity.render-pipelines.core/Documentation~/get-custom-graphics-settings.md index 1b30039b513..8cbff7e4c59 100644 --- a/Packages/com.unity.render-pipelines.core/Documentation~/get-custom-graphics-settings.md +++ b/Packages/com.unity.render-pipelines.core/Documentation~/get-custom-graphics-settings.md @@ -2,9 +2,7 @@ To get a custom setting and read its value, use the `GetRenderPipelineSettings` method. -If you want to get a setting at runtime, you must [include the setting in your build](choose-whether-unity-includes-a-graphics-setting-in-your-build.md). - -For example, the following script gets the `MySettings` settings class from the example in the [Add custom graphics settings](add-custom-graphics-settings.md) page, then logs the value of the `MyValue` setting: +For example, the following script gets the `MySettings` settings class from the example in the [Add a setting](add-custom-graphics-setting.md) page, then logs the value of the `mySetting` setting: ```c# using UnityEngine; @@ -19,16 +17,16 @@ public class LogMySettingsValue : MonoBehaviour var mySettings = GraphicsSettings.GetRenderPipelineSettings(); // Log the value of the MyValue setting - Debug.Log(mySettings.myValue); + Debug.Log(mySettings.mySetting); } } ``` -## Detect when a setting changes +## Get a notification when a setting changes -You can configure a property so it notifies other scripts when its value changes. This only works while you're editing your project, not at runtime. +To configure a property so it notifies other scripts when its value changes, use the `SetValueAndNotify` method. You can use this to debug, update UI elements, or trigger other actions when a setting changes. -You can use this to fetch the value only when it changes, instead of every frame in the `Update()` method. +This only works while you're editing your project, not at runtime. If you use `SetValueAndModify` in a built application, Unity throws an exception. Follow these steps: @@ -63,8 +61,6 @@ Follow these steps: } ``` - If you use `SetValueAndModify' in a standalone application, Unity throws an exception. - 3. Use the `GraphicsSettings.Subscribe` method to subscribe to notifications from the setting, and call an `Action` when the setting changes. For example: @@ -101,4 +97,6 @@ To stop calling a method when a setting changes, use the `GraphicsSettings.Unsub GraphicsSettings.Unsubscribe(onSettingChanged); ``` +## Additional resources +- [`IRenderPipelineGraphicsSettings`](https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Rendering.IRenderPipelineGraphicsSettings.html) diff --git a/Packages/com.unity.render-pipelines.core/Documentation~/settings.md b/Packages/com.unity.render-pipelines.core/Documentation~/settings.md index 28e67b49180..edc8c94bece 100644 --- a/Packages/com.unity.render-pipelines.core/Documentation~/settings.md +++ b/Packages/com.unity.render-pipelines.core/Documentation~/settings.md @@ -1,10 +1,16 @@ -# Custom settings +# Custom graphics settings -Add custom properties and settings to a Scriptable Render Pipeline. +Add, store, and manage custom settings that control rendering features and behaviours in a Scriptable Render Pipeline. For example, quality or shader settings. |Page|Description| |-|-| |[Adding properties in the menu](adding-properties.md)|Add properties in the **Core Render Pipeline** settings section.| -|[Add custom graphics settings](add-custom-graphics-settings.md)|Add custom graphics settings to the **Edit** > **Project Settings** > **Graphics** window, then use the values of the settings to customize your build.| +|[Add a settings group](add-custom-graphics-settings.md)|To add custom graphics settings to a Scriptable Render Pipeline, implement the `IRenderPipelineGraphicsSettings` interface. | +|[Add a setting](add-custom-graphics-setting.md)|Add a simple property or a reference property to a custom graphics settings group.| +|[Customize the UI of a setting](customize-ui-for-a-setting.md)|Customize how a setting displays in the graphics settings window, or add items to the **More** (⋮) menu of a settings group.| |[Get custom graphics settings](get-custom-graphics-settings.md)|Get a custom graphics setting and read its value, or detect when a setting changes.| |[Include or exclude a setting in your build](choose-whether-unity-includes-a-graphics-setting-in-your-build.md)|Choose whether Unity includes or strips a graphics setting in your build, and check if a build includes a setting.| + +## Additional resources + +- [Graphics settings](xref:class-GraphicsSettings) in the Unity manual diff --git a/Packages/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.Builtins.cs b/Packages/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.Builtins.cs index cb89a14027a..f5bed0d0d3d 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.Builtins.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.Builtins.cs @@ -830,7 +830,10 @@ public override bool OnGUI(DebugUI.Widget widget, DebugState state) rowRect.xMin += 2; rowRect.xMax -= 2; - EditorGUI.LabelField(rowRect, GUIContent.none, EditorGUIUtility.TrTextContent(row.displayName), DebugWindow.Styles.centeredLeft); + + bool isAlternate = r % 2 == 0; + + EditorGUI.LabelField(rowRect, GUIContent.none, EditorGUIUtility.TrTextContent(row.displayName),isAlternate ? DebugWindow.Styles.centeredLeft : DebugWindow.Styles.centeredLeftAlternate); rowRect.xMin -= 2; rowRect.xMax += 2; @@ -841,7 +844,7 @@ public override bool OnGUI(DebugUI.Widget widget, DebugState state) rowRect.x += rowRect.width; rowRect.width = columns[visible[c]].width; if (!row.isHidden) - DisplayChild(rowRect, row.children[visible[c] - 1]); + DisplayChild(rowRect, row.children[visible[c] - 1], isAlternate); } rowRect.y += rowRect.height; } @@ -884,7 +887,7 @@ internal Rect DrawOutline(Rect rect) return new Rect(rect.x + size, rect.y + size, rect.width - 2 * size, rect.height - 2 * size); } - internal void DisplayChild(Rect rect, DebugUI.Widget child) + internal void DisplayChild(Rect rect, DebugUI.Widget child, bool isAlternate) { rect.xMin += 2; rect.xMax -= 2; @@ -898,7 +901,7 @@ internal void DisplayChild(Rect rect, DebugUI.Widget child) if (child.GetType() == typeof(DebugUI.Value)) { var widget = Cast(child); - EditorGUI.LabelField(rect, GUIContent.none, EditorGUIUtility.TrTextContent(widget.GetValue().ToString())); + EditorGUI.LabelField(rect, GUIContent.none, EditorGUIUtility.TrTextContent(widget.GetValue().ToString()), isAlternate ? DebugWindow.Styles.centeredLeft : DebugWindow.Styles.centeredLeftAlternate); } else if (child.GetType() == typeof(DebugUI.ColorField)) { diff --git a/Packages/com.unity.render-pipelines.core/Editor/Debugging/DebugWindow.cs b/Packages/com.unity.render-pipelines.core/Editor/Debugging/DebugWindow.cs index 4de92d66a93..c8eae3cd2f3 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Debugging/DebugWindow.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Debugging/DebugWindow.cs @@ -11,7 +11,6 @@ using UnityEngine; using UnityEngine.Assertions; using UnityEngine.Rendering; - using PackageInfo = UnityEditor.PackageManager.PackageInfo; namespace UnityEditor.Rendering @@ -626,6 +625,7 @@ public class Styles public readonly Color skinBackgroundColor; public static GUIStyle centeredLeft = new GUIStyle(EditorStyles.label) { alignment = TextAnchor.MiddleLeft }; + public static GUIStyle centeredLeftAlternate = new GUIStyle(EditorStyles.label) { alignment = TextAnchor.MiddleLeft }; public static float singleRowHeight = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; public static int foldoutColumnWidth = 70; @@ -637,6 +637,12 @@ public Styles() Color backgroundColorDarkSkin = new Color32(38, 38, 38, 128); Color backgroundColorLightSkin = new Color32(128, 128, 128, 96); + centeredLeftAlternate.normal.background = CoreEditorUtils.CreateColoredTexture2D( + EditorGUIUtility.isProSkin + ? new Color(63 / 255.0f, 63 / 255.0f, 63 / 255.0f, 255 / 255.0f) + : new Color(202 / 255.0f, 202 / 255.0f, 202 / 255.0f, 255 / 255.0f), + "centeredLeftAlternate Background"); + sectionScrollView = new GUIStyle(sectionScrollView); sectionScrollView.overflow.bottom += 1; @@ -650,6 +656,15 @@ public Styles() skinBackgroundColor = EditorGUIUtility.isProSkin ? backgroundColorDarkSkin : backgroundColorLightSkin; labelWithZeroValueStyle.normal.textColor = Color.gray; + + // Make sure that textures are unloaded on domain reloads. + void OnBeforeAssemblyReload() + { + UnityEngine.Object.DestroyImmediate(centeredLeftAlternate.normal.background); + AssemblyReloadEvents.beforeAssemblyReload -= OnBeforeAssemblyReload; + } + + AssemblyReloadEvents.beforeAssemblyReload += OnBeforeAssemblyReload; } } diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.LightTransport.cs b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.LightTransport.cs index a0be9e1a2b9..67d6182f5d9 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.LightTransport.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.LightTransport.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Runtime.CompilerServices; using Unity.Collections; using UnityEditor; @@ -8,7 +9,7 @@ using UnityEngine.LightTransport.PostProcessing; using UnityEngine.Rendering.Sampling; using UnityEngine.Rendering.UnifiedRayTracing; - +using UnityEngine.SceneManagement; using TouchupVolumeWithBoundsList = System.Collections.Generic.List<(UnityEngine.Rendering.ProbeReferenceVolume.Volume obb, UnityEngine.Bounds aabb, UnityEngine.Rendering.ProbeAdjustmentVolume volume)>; namespace UnityEngine.Rendering @@ -584,13 +585,16 @@ public void Dispose() } } + // The contribution from all Baked and Mixed lights in the scene should be disabled to avoid double contribution. static void UpdateLightStatus() { var lightingSettings = ProbeVolumeLightingTab.GetLightingSettings(); - // The contribution from all Baked and Mixed lights in the scene should be disabled to avoid double contribution. - var lights = Object.FindObjectsByType(FindObjectsSortMode.None); - foreach (var light in lights) + var sceneLights = new Dictionary>(); + + // Modify each baked light, take note of which scenes they belong to. + var allLights = Object.FindObjectsByType(FindObjectsSortMode.None); + foreach (var light in allLights) { if (light.lightmapBakeType != LightmapBakeType.Realtime) { @@ -600,6 +604,56 @@ static void UpdateLightStatus() bakingOutput.mixedLightingMode = lightingSettings.mixedBakeMode; light.bakingOutput = bakingOutput; } + + // Take note of the lights from each scene + var scene = light.gameObject.scene; + if (!sceneLights.TryGetValue(scene, out var sceneLightList)) + { + sceneLightList = new List(); + sceneLights.Add(scene, sceneLightList); + } + sceneLightList.Add(light); + } + + // Now we make the modifications persistent by modifying Lighting Data Assets (LDA) on disk. + string ldaFolderPath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(m_BakingSet)); + for (int i = 0; i < m_BakingSet.sceneGUIDs.Count; i++) + { + string guid = m_BakingSet.sceneGUIDs[i]; + Scene scene = SceneManager.GetSceneByPath(AssetDatabase.GUIDToAssetPath(guid)); + if (!scene.isLoaded) + continue; + + LightingDataAsset prevLDA = Lightmapping.GetLightingDataAssetForScene(scene); + LightingDataAsset newLDA = prevLDA; + + // If the scene has no (modifiable) LDA, create a new one. + bool isDefaultLDA = prevLDA && prevLDA.hideFlags.HasFlag(HideFlags.NotEditable); + if (prevLDA == null || isDefaultLDA) + { + newLDA = new LightingDataAsset(scene); + } + + // Update the LDA with the new light settings + if (sceneLights.TryGetValue(scene, out var lights)) + newLDA.SetLights(lights.ToArray()); + else + newLDA.SetLights(Array.Empty()); + + // If the scene was using the builtin/default LDA before, copy over environment lighting, so it doesn't change. + if (prevLDA != null) + { + newLDA.SetAmbientProbe(prevLDA.GetAmbientProbe()); + newLDA.SetDefaultReflectionCubemap(prevLDA.GetDefaultReflectionCubemap()); + } + + // Save the LDA to disk and assign it to the scene. + if (newLDA != prevLDA) + { + string ldaPath = $"{ldaFolderPath}/LightingData-{i}.asset".Replace('\\', '/'); + AssetDatabase.CreateAsset(newLDA, ldaPath); + Lightmapping.SetLightingDataAssetForScene(scene, newLDA); + } } } diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.Serialization.cs b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.Serialization.cs index d0dadf25dc2..7550d21a9af 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.Serialization.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.Serialization.cs @@ -1046,9 +1046,13 @@ unsafe static void WriteBakingCells(BakingCell[] bakingCells) { WriteNativeArray(fs, probesL2); } - using (var fs = new System.IO.FileStream(cellProbeOcclusionDataFilename, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite)) + if (probeOcclusion.Length > 0) { - WriteNativeArray(fs, probeOcclusion); + // Write the probe occlusion data file, only if this data was baked (shadowmask mode) - UUM-85411 + using (var fs = new System.IO.FileStream(cellProbeOcclusionDataFilename, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite)) + { + WriteNativeArray(fs, probeOcclusion); + } } using (var fs = new System.IO.FileStream(cellSharedDataFilename, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite)) { diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.cs b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.cs index e54acb2bfd8..922c77f8979 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.cs @@ -1234,7 +1234,7 @@ static void FixSeams(NativeArray positionRemap, NativeArray positi // the dilation process consits in doing a trilinear sample of the higher subdivision brick and override the lower subdiv with that // We have to mark the probes on the boundary as valid otherwise leak reduction at runtime will interfere with this method - + // Use an indirection structure to ensure mem usage stays reasonable VoxelToBrickCache cache = new VoxelToBrickCache(); diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeLightingTab.cs b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeLightingTab.cs index 6da03237a47..8aaa605c3c5 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeLightingTab.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeLightingTab.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Reflection; using System.Collections.Generic; +using System.IO; using UnityEditor; using UnityEditor.Rendering; using UnityEditor.SceneManagement; @@ -510,7 +511,9 @@ void SaveTempBakingSetIfNeeded() string path = string.IsNullOrEmpty(scene.path) ? ProbeVolumeBakingSet.GetDirectory("Assets/", "Untitled") : ProbeVolumeBakingSet.GetDirectory(scene.path, scene.name); - path = System.IO.Path.Combine(path, activeSet.name + ".asset"); + if (!Directory.Exists(path)) + Directory.CreateDirectory(path); + path = Path.Combine(path, activeSet.name + ".asset"); path = AssetDatabase.GenerateUniqueAssetPath(path); AssetDatabase.CreateAsset(activeSet, path); @@ -1012,7 +1015,7 @@ internal bool PrepareAPVBake() if (AdaptiveProbeVolumes.partialBakeSceneList.Count == activeSet.sceneGUIDs.Count) AdaptiveProbeVolumes.partialBakeSceneList = null; - if (ProbeReferenceVolume.instance.supportLightingScenarios && !activeSet.m_LightingScenarios.Contains(activeSet.lightingScenario)) + if (ProbeReferenceVolume.instance.supportLightingScenarios && !activeSet.m_LightingScenarios.Contains(activeSet.lightingScenario) && activeSet.m_LightingScenarios.Count > 0) activeSet.SetActiveScenario(activeSet.m_LightingScenarios[0], false); // Layout has changed and is incompatible. diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugDisplaySettingsVolumes.cs b/Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugDisplaySettingsVolumes.cs index eb34eeaf04d..f7f88572b5f 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugDisplaySettingsVolumes.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugDisplaySettingsVolumes.cs @@ -39,16 +39,19 @@ static class Strings public static readonly string camera = "Camera"; public static readonly string parameter = "Parameter"; public static readonly string component = "Component"; - public static readonly string debugViewNotSupported = "Debug view not supported"; + public static readonly string debugViewNotSupported = "N/A"; + public static readonly string parameterNotOverrided = "-"; public static readonly string volumeInfo = "Volume Info"; + public static readonly string gameObject = "GameObject"; public static readonly string resultValue = "Result"; public static readonly string resultValueTooltip = "The interpolated result value of the parameter. This value is used to render the camera."; - public static readonly string globalDefaultValue = "Default"; + public static readonly string globalDefaultValue = "Graphics Settings"; public static readonly string globalDefaultValueTooltip = "Default value for this parameter, defined by the Default Volume Profile in Global Settings."; - public static readonly string qualityLevelValue = "SRP Asset"; + public static readonly string qualityLevelValue = "Quality Settings"; public static readonly string qualityLevelValueTooltip = "Override value for this parameter, defined by the Volume Profile in the current SRP Asset."; public static readonly string global = "Global"; public static readonly string local = "Local"; + public static readonly string volumeProfile = "Volume Profile"; } const string k_PanelTitle = "Volume"; @@ -107,40 +110,26 @@ public static DebugUI.ObjectPopupField CreateCameraSelector(SettingsPanel panel, }; } - static DebugUI.Widget CreateVolumeParameterWidget(string name, VolumeParameter param, Func isHiddenCallback = null) + static DebugUI.Widget CreateVolumeParameterWidget(string name, bool isResultParameter, VolumeParameter param, Func isHiddenCallback = null) { - if (param == null) - return new DebugUI.Value() { displayName = name, getter = () => "-" }; - - var parameterType = param.GetType(); - - // Special overrides - if (parameterType == typeof(ColorParameter)) +#if UNITY_EDITOR || DEVELOPMENT_BUILD + if (param != null) { - var p = (ColorParameter)param; - return new DebugUI.ColorField() + var parameterType = param.GetType(); + if (parameterType == typeof(ColorParameter)) { - displayName = name, - hdr = p.hdr, - showAlpha = p.showAlpha, - getter = () => p.value, - setter = value => p.value = value, - isHiddenCallback = isHiddenCallback - }; - } - else if (parameterType == typeof(BoolParameter)) - { - var p = (BoolParameter)param; - return new DebugUI.BoolField() - { - displayName = name, - getter = () => p.value, - setter = value => p.value = value, - isHiddenCallback = isHiddenCallback - }; - } - else - { + var p = (ColorParameter)param; + return new DebugUI.ColorField() + { + displayName = name, + hdr = p.hdr, + showAlpha = p.showAlpha, + getter = () => p.value, + setter = value => p.value = value, + isHiddenCallback = isHiddenCallback + }; + } + var typeInfo = parameterType.GetTypeInfo(); var genericArguments = typeInfo.BaseType.GenericTypeArguments; if (genericArguments.Length > 0 && genericArguments[0].IsArray) @@ -152,247 +141,201 @@ static DebugUI.Widget CreateVolumeParameterWidget(string name, VolumeParameter p type = parameterType }; } - } - // For parameters that do not override `ToString` - var property = param.GetType().GetProperty("value"); - var toString = property.PropertyType.GetMethod("ToString", Type.EmptyTypes); - if ((toString == null) || (toString.DeclaringType == typeof(object)) || (toString.DeclaringType == typeof(UnityEngine.Object))) - { - // Check if the parameter has a name - var nameProp = property.PropertyType.GetProperty("name"); - if (nameProp == null) - return new DebugUI.Value() { displayName = name, getter = () => Strings.debugViewNotSupported }; - - // Return the parameter name return new DebugUI.Value() { displayName = name, getter = () => { - var value = property.GetValue(param); - if (value == null || value.Equals(null)) - return Strings.none; - var valueString = nameProp.GetValue(value); - return valueString ?? Strings.none; + var property = param.GetType().GetProperty("value"); + if (property == null) + return "-"; + + if (isResultParameter || param.overrideState) + { + var value = property.GetValue(param); + var propertyType = property.PropertyType; + if (value == null || value.Equals(null)) + return Strings.none + $" ({propertyType.Name})"; + + var toString = propertyType.GetMethod("ToString", Type.EmptyTypes); + if ((toString == null) || (toString.DeclaringType == typeof(object)) || (toString.DeclaringType == typeof(UnityEngine.Object))) + { + // Check if the parameter has a name + var nameProp = property.PropertyType.GetProperty("name"); + if (nameProp == null) + return Strings.debugViewNotSupported; + + var valueString = nameProp.GetValue(value); + return valueString ?? Strings.none; + } + + return value.ToString(); + } + + return Strings.parameterNotOverrided; }, isHiddenCallback = isHiddenCallback }; } - - // Call the ToString method - return new DebugUI.Value() - { - displayName = name, - getter = () => - { - var value = property.GetValue(param); - return value == null ? Strings.none : value.ToString(); - }, - isHiddenCallback = isHiddenCallback - }; + #endif + return new DebugUI.Value(); } static DebugUI.Value s_EmptyDebugUIValue = new DebugUI.Value { getter = () => string.Empty }; - public static DebugUI.Table CreateVolumeTable(DebugDisplaySettingsVolume data) + struct VolumeParameterChain { - var table = new DebugUI.Table() + public DebugUI.Widget.NameAndTooltip nameAndTooltip; + public VolumeProfile volumeProfile; + public VolumeComponent volumeComponent; + public Volume volume; + } + + static VolumeComponent GetSelectedVolumeComponent(VolumeProfile profile, Type selectedType) + { + if (profile != null) { - displayName = Strings.parameter, - isReadOnly = true, - isHiddenCallback = () => data.volumeDebugSettings.selectedComponent == 0 - }; + foreach (var component in profile.components) + if (component.GetType() == selectedType) + return component; + } + return null; + } + + static List GetResolutionChain(DebugDisplaySettingsVolume data) + { + List chain = new List(); Type selectedType = data.volumeDebugSettings.selectedComponentType; if (selectedType == null) - return table; + return chain; var volumeManager = VolumeManager.instance; var stack = data.volumeDebugSettings.selectedCameraVolumeStack ?? volumeManager.stack; var stackComponent = stack.GetComponent(selectedType); if (stackComponent == null) - return table; - - var volumes = data.volumeDebugSettings.GetVolumes(); + return chain; - // First row for volume info - var row1 = new DebugUI.Table.Row() + var result = new VolumeParameterChain() { - displayName = Strings.volumeInfo, - opened = true, // Open by default for the in-game view - children = + nameAndTooltip = new DebugUI.Widget.NameAndTooltip() { - new DebugUI.Value() - { - displayName = Strings.resultValue, - tooltip = Strings.resultValueTooltip, - getter = () => string.Empty - } - } - }; - - // Second row, links to volume gameobjects - var row2 = new DebugUI.Table.Row() - { - displayName = "GameObject", - children = { s_EmptyDebugUIValue } - }; - - // Third row, links to volume profile assets - var row3 = new DebugUI.Table.Row() - { - displayName = "Volume Profile", - children = { s_EmptyDebugUIValue } + name = Strings.resultValue, + tooltip = Strings.resultValueTooltip, + }, + volumeComponent = stackComponent, }; - // Fourth row, empty (to separate from actual data) - var row4 = new DebugUI.Table.Row() - { - displayName = string.Empty , - children = { s_EmptyDebugUIValue } - }; + chain.Add(result); + // Add volume components that override default values + var volumes = data.volumeDebugSettings.GetVolumes(); foreach (var volume in volumes) { var profile = volume.HasInstantiatedProfile() ? volume.profile : volume.sharedProfile; - row1.children.Add(new DebugUI.Value() + var overrideComponent = GetSelectedVolumeComponent(profile, selectedType); + if (overrideComponent != null) { - displayName = profile.name, - tooltip = $"Override value for this parameter, defined by {profile.name}", - getter = () => + var overrideVolume = new VolumeParameterChain() { - var scope = volume.isGlobal ? Strings.global : Strings.local; - var weight = data.volumeDebugSettings.GetVolumeWeight(volume); - return scope + " (" + (weight * 100f) + "%)"; - } - }); - row2.children.Add(new DebugUI.ObjectField() { displayName = string.Empty, getter = () => volume }); - row3.children.Add(new DebugUI.ObjectField() { displayName = string.Empty, getter = () => profile }); - row4.children.Add(s_EmptyDebugUIValue); + nameAndTooltip = new DebugUI.Widget.NameAndTooltip() + { + name = profile.name, + tooltip = profile.name, + }, + volumeProfile = profile, + volumeComponent = overrideComponent, + volume = volume + }; + chain.Add(overrideVolume); + } } - // Default value profiles - var globalDefaultComponent = GetSelectedVolumeComponent(volumeManager.globalDefaultProfile); - var qualityDefaultComponent = GetSelectedVolumeComponent(volumeManager.qualityDefaultProfile); - List<(VolumeProfile, VolumeComponent)> customDefaultComponents = new(); + // Add custom default profiles if (volumeManager.customDefaultProfiles != null) { foreach (var customProfile in volumeManager.customDefaultProfiles) { - var customDefaultComponent = GetSelectedVolumeComponent(customProfile); - if (customDefaultComponent != null) - customDefaultComponents.Add((customProfile, customDefaultComponent)); + var customProfileComponent = GetSelectedVolumeComponent(customProfile, selectedType); + if (customProfileComponent != null) + { + var overrideVolume = new VolumeParameterChain() + { + nameAndTooltip = new DebugUI.Widget.NameAndTooltip() + { + name = customProfile.name, + tooltip = customProfile.name, + }, + volumeProfile = customProfile, + volumeComponent = customProfileComponent, + }; + chain.Add(overrideVolume); + } } } - foreach (var (customProfile, _) in customDefaultComponents) - { - row1.children.Add(new DebugUI.Value() { displayName = customProfile.name, getter = () => string.Empty }); - row2.children.Add(s_EmptyDebugUIValue); - row3.children.Add(new DebugUI.ObjectField() { displayName = string.Empty, getter = () => customProfile }); - row4.children.Add(s_EmptyDebugUIValue); - } - - row1.children.Add(new DebugUI.Value() { displayName = Strings.qualityLevelValue, tooltip = Strings.qualityLevelValueTooltip, getter = () => string.Empty }); - row2.children.Add(s_EmptyDebugUIValue); - row3.children.Add(new DebugUI.ObjectField() { displayName = string.Empty, getter = () => volumeManager.qualityDefaultProfile }); - row4.children.Add(s_EmptyDebugUIValue); - - row1.children.Add(new DebugUI.Value() { displayName = Strings.globalDefaultValue, tooltip = Strings.globalDefaultValueTooltip, getter = () => string.Empty }); - row2.children.Add(s_EmptyDebugUIValue); - row3.children.Add(new DebugUI.ObjectField() { displayName = string.Empty, getter = () => volumeManager.globalDefaultProfile }); - row4.children.Add(s_EmptyDebugUIValue); - - table.children.Add(row1); - table.children.Add(row2); - table.children.Add(row3); - table.children.Add(row4); - - VolumeComponent GetSelectedVolumeComponent(VolumeProfile profile) + // Add Quality Settings + if (volumeManager.globalDefaultProfile != null) { - if (profile != null) + var qualitySettingsComponent = GetSelectedVolumeComponent(volumeManager.qualityDefaultProfile, selectedType); + if (qualitySettingsComponent != null) { - foreach (var component in profile.components) - if (component.GetType() == selectedType) - return component; + var overrideVolume = new VolumeParameterChain() + { + nameAndTooltip = new DebugUI.Widget.NameAndTooltip() + { + name = Strings.qualityLevelValue, + tooltip = Strings.qualityLevelValueTooltip, + }, + volumeProfile = volumeManager.qualityDefaultProfile, + volumeComponent = qualitySettingsComponent, + }; + chain.Add(overrideVolume); } - return null; } - // Build rows - recursively handles nested parameters - var rows = new List(); - int AddParameterRows(Type type, string baseName = null, int skip = 0) + // Add Graphics Settings + if (volumeManager.globalDefaultProfile != null) { - void AddRow(FieldInfo f, string prefix, int skip) + var graphicsSettingsComponent = GetSelectedVolumeComponent(volumeManager.globalDefaultProfile, selectedType); + if (graphicsSettingsComponent != null) { - var fieldName = prefix + f.Name; - var attr = (DisplayInfoAttribute[])f.GetCustomAttributes(typeof(DisplayInfoAttribute), true); - if (attr.Length != 0) - fieldName = prefix + attr[0].name; -#if UNITY_EDITOR - // Would be nice to have the equivalent for the runtime debug. - else - fieldName = UnityEditor.ObjectNames.NicifyVariableName(fieldName); -#endif - - int currentParam = rows.Count + skip; - DebugUI.Table.Row row = new DebugUI.Table.Row() + var overrideVolume = new VolumeParameterChain() { - displayName = fieldName, - children = { CreateVolumeParameterWidget(Strings.resultValue, stackComponent.parameterList[currentParam]) }, + nameAndTooltip = new DebugUI.Widget.NameAndTooltip() + { + name = Strings.globalDefaultValue, + tooltip = Strings.globalDefaultValueTooltip, + }, + volumeProfile = volumeManager.globalDefaultProfile, + volumeComponent = graphicsSettingsComponent, }; - - foreach (var volume in volumes) - { - VolumeParameter param = null; - var profile = volume.HasInstantiatedProfile() ? volume.profile : volume.sharedProfile; - if (profile.TryGet(selectedType, out VolumeComponent component)) - param = component.parameterList[currentParam]; - row.children.Add(CreateVolumeParameterWidget(volume.name + " (" + profile.name + ")", param, () => !component.parameterList[currentParam].overrideState)); - } - - foreach (var (customProfile, customComponent) in customDefaultComponents) - row.children.Add(CreateVolumeParameterWidget(customProfile.name, - customComponent != null ? customComponent.parameterList[currentParam] : null)); - - row.children.Add(CreateVolumeParameterWidget(Strings.qualityLevelValue, - qualityDefaultComponent != null ? qualityDefaultComponent.parameterList[currentParam] : null)); - - row.children.Add(CreateVolumeParameterWidget(Strings.globalDefaultValue, - globalDefaultComponent != null ? globalDefaultComponent.parameterList[currentParam] : null)); - - rows.Add(row); - } - - var fields = type - .GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) - .OrderBy(t => t.MetadataToken); - foreach (var field in fields) - { - if (field.GetCustomAttributes(typeof(ObsoleteAttribute), false).Length != 0) - { - skip++; - continue; - } - var fieldType = field.FieldType; - if (fieldType.IsSubclassOf(typeof(VolumeParameter))) - AddRow(field, baseName ?? string.Empty, skip); - else if (!fieldType.IsArray && fieldType.IsClass) - skip += AddParameterRows(fieldType, baseName ?? (field.Name + " "), skip); + chain.Add(overrideVolume); } - return skip; } - AddParameterRows(selectedType); - foreach (var r in rows.OrderBy(t => t.displayName)) - table.children.Add(r); + return chain; + } + + public static DebugUI.Table CreateVolumeTable(DebugDisplaySettingsVolume data) + { + var table = new DebugUI.Table() + { + displayName = Strings.parameter, + isReadOnly = true, + isHiddenCallback = () => data.volumeDebugSettings.selectedComponent == 0 + }; + + var resolutionChain = GetResolutionChain(data); + if (resolutionChain.Count == 0) + return table; - data.volumeDebugSettings.RefreshVolumes(volumes); - for (int i = 0; i < volumes.Length; i++) - table.SetColumnVisibility(i + 1, data.volumeDebugSettings.VolumeHasInfluence(volumes[i])); + GenerateTableRows(table, resolutionChain); + GenerateTableColumns(table, data, resolutionChain); float timer = 0.0f, refreshRate = 0.2f; + var volumes = data.volumeDebugSettings.GetVolumes(); table.isHiddenCallback = () => { timer += Time.deltaTime; @@ -400,16 +343,9 @@ void AddRow(FieldInfo f, string prefix, int skip) { if (data.volumeDebugSettings.selectedCamera != null) { - var newVolumes = data.volumeDebugSettings.GetVolumes(); - if (!data.volumeDebugSettings.RefreshVolumes(newVolumes)) - { - for (int i = 0; i < newVolumes.Length; i++) - { - var visible = data.volumeDebugSettings.VolumeHasInfluence(newVolumes[i]); - table.SetColumnVisibility(i + 1, visible); - } - } + SetTableColumnVisibility(data, table); + var newVolumes = data.volumeDebugSettings.GetVolumes(); if (!volumes.SequenceEqual(newVolumes)) { volumes = newVolumes; @@ -424,6 +360,139 @@ void AddRow(FieldInfo f, string prefix, int skip) return table; } + + private static void SetTableColumnVisibility(DebugDisplaySettingsVolume data, DebugUI.Table table) + { + var newResolutionChain = GetResolutionChain(data); + for (int i = 1; i < newResolutionChain.Count; i++) // We always skip the interpolated stack that is in index 0 + { + bool visible = true; + if (newResolutionChain[i].volume != null) + { + visible = data.volumeDebugSettings.VolumeHasInfluence(newResolutionChain[i].volume); + } + else + { + visible = newResolutionChain[i].volumeComponent.active; + + if (visible) + { + bool atLeastOneParameterIsOverriden = false; + foreach (var parameter in newResolutionChain[i].volumeComponent.parameterList) + { + if (parameter.overrideState == true) + { + atLeastOneParameterIsOverriden = true; + break; + } + } + + visible &= atLeastOneParameterIsOverriden; + } + } + + table.SetColumnVisibility(i, visible); + } + } + + private static void GenerateTableColumns(DebugUI.Table table, DebugDisplaySettingsVolume data, List resolutionChain) + { + for (int i = 0; i < resolutionChain.Count; ++i) + { + var chain = resolutionChain[i]; + int iRowIndex = -1; + + if (chain.volume != null) + { + ((DebugUI.Table.Row)table.children[++iRowIndex]).children.Add(new DebugUI.Value() + { + nameAndTooltip = chain.nameAndTooltip, + getter = () => + { + var scope = chain.volume.isGlobal ? Strings.global : Strings.local; + var weight = data.volumeDebugSettings.GetVolumeWeight(chain.volume); + return scope + " (" + (weight * 100f) + "%)"; + }, + refreshRate = 0.2f + }); + ((DebugUI.Table.Row)table.children[++iRowIndex]).children.Add(new DebugUI.ObjectField() { displayName = string.Empty, getter = () => chain.volume }); + } + else + { + ((DebugUI.Table.Row)table.children[++iRowIndex]).children.Add(new DebugUI.Value() + { + nameAndTooltip = chain.nameAndTooltip, + getter = () => string.Empty + }); + ((DebugUI.Table.Row)table.children[++iRowIndex]).children.Add(s_EmptyDebugUIValue); + } + + ((DebugUI.Table.Row)table.children[++iRowIndex]).children.Add(chain.volumeProfile != null ? new DebugUI.ObjectField() { displayName = string.Empty, getter = () => chain.volumeProfile } : + s_EmptyDebugUIValue); + + ((DebugUI.Table.Row)table.children[++iRowIndex]).children.Add(s_EmptyDebugUIValue); + + bool isResultParameter = i == 0; + for (int j = 0; j < chain.volumeComponent.parameterList.Count; ++j) + { + var parameter = chain.volumeComponent.parameterList[j]; + ((DebugUI.Table.Row)table.children[++iRowIndex]).children.Add(CreateVolumeParameterWidget(chain.nameAndTooltip.name, isResultParameter, parameter)); + } + } + } + + private static void GenerateTableRows(DebugUI.Table table, List resolutionChain) + { + // First row for volume info + var volumeInfoRow = new DebugUI.Table.Row() + { + displayName = Strings.volumeInfo, + opened = true, // Open by default for the in-game view + }; + + table.children.Add(volumeInfoRow); + + // Second row, links to volume gameobjects + var gameObjectRow = new DebugUI.Table.Row() + { + displayName = Strings.gameObject, + }; + + table.children.Add(gameObjectRow); + + // Third row, links to volume profile assets + var volumeProfileRow = new DebugUI.Table.Row() + { + displayName = Strings.volumeProfile, + }; + table.children.Add(volumeProfileRow); + + var separatorRow = new DebugUI.Table.Row() + { + displayName = string.Empty , + }; + + table.children.Add(separatorRow); + + var results = resolutionChain[0].volumeComponent; + for (int i = 0; i < results.parameterList.Count; ++i) + { + var parameter = results.parameterList[i]; + +#if UNITY_EDITOR + string displayName = UnityEditor.ObjectNames.NicifyVariableName(parameter.debugId); // In the editor, make the name more readable +#elif DEVELOPMENT_BUILD + string displayName = parameter.debugId; // In the development player, just the debug id +#else + string displayName = i.ToString(); // Everywhere else, just a dummy id ( TODO: The Volume panel code should be stripped completely in nom-development builds ) +#endif + + table.children.Add(new DebugUI.Table.Row() + { + displayName = displayName + }); + } + } } [DisplayInfo(name = k_PanelTitle, order = int.MaxValue)] diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs b/Packages/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs index ca423bffbed..d2310ebd81b 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Debugging/VolumeDebugSettings.cs @@ -73,7 +73,10 @@ public IEnumerable cameras if (camera.cameraType != CameraType.Preview && camera.cameraType != CameraType.Reflection) { - if (camera.TryGetComponent(out T additionalData)) + if (!camera.TryGetComponent(out T additionalData)) + additionalData = camera.gameObject.AddComponent(); + + if (additionalData != null) m_Cameras.Add(camera); } } @@ -262,21 +265,9 @@ public bool RefreshVolumes(Volume[] newVolumes) /// The weight of the volume public float GetVolumeWeight(Volume volume) { - if (weights == null) - return 0; - - float total = 0f, weight = 0f; - for (int i = 0; i < volumes.Length; i++) - { - weight = weights[i]; - weight *= 1f - total; - total += weight; - - if (volumes[i] == volume) - return weight; - } - - return 0f; + // TODO: Store the calculated weight in the stack for the volumes that have influence and return it here + var triggerPos = selectedCameraPosition; + return ComputeWeight(volume, triggerPos); } /// @@ -286,14 +277,9 @@ public float GetVolumeWeight(Volume volume) /// If the volume has influence public bool VolumeHasInfluence(Volume volume) { - if (weights == null) - return false; - - int index = Array.IndexOf(volumes, volume); - if (index == -1) - return false; - - return weights[index] != 0f; + // TODO: Store the calculated weight in the stack for the volumes that have influence and return it here + var triggerPos = selectedCameraPosition; + return ComputeWeight(volume, triggerPos) > 0.0f; } } } diff --git a/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentDrawer.Validator.cs b/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentDrawer.Validator.cs index 91a5c2cfba0..f76c930b549 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentDrawer.Validator.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentDrawer.Validator.cs @@ -81,6 +81,11 @@ internal static bool IsGPUResidentDrawerSupportedBySRP(GPUResidentDrawerSettings message = Strings.allowInEditModeDisabled; return false; } + + // Disable GRD in any external AssetImporter child process. GRD isn't made for AssetImporter workflow/lifetime + // Avoid memory leak warning messages and also some future issues (UUM-90039) + if (AssetDatabase.IsAssetImportWorkerProcess()) + return false; #endif // If we are forcing the system, no need to perform further checks if (IsForcedOnViaCommandLine()) diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.Streaming.cs b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.Streaming.cs index abb57ee39f4..87945b9c4f9 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.Streaming.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.Streaming.cs @@ -114,6 +114,7 @@ internal class CellStreamingScratchBuffer public CellStreamingScratchBuffer(int chunkCount, int chunkSize, bool allocateGraphicsBuffers) { this.chunkCount = chunkCount; + this.chunkSize = chunkSize; // With a stride of 4 (one uint) // Number of elements for chunk data: chunkCount * chunkSize / 4 @@ -152,6 +153,7 @@ public void Dispose() public GraphicsBuffer buffer => m_GraphicsBuffers[m_CurrentBuffer]; public NativeArray stagingBuffer; // Contains data streamed from disk. To be copied into the graphics buffer. public int chunkCount { get; } + public int chunkSize { get; } int m_CurrentBuffer; GraphicsBuffer[] m_GraphicsBuffers = new GraphicsBuffer[2]; diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.cs b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.cs index e32a7070b43..a9eadd77de4 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.cs @@ -1379,7 +1379,7 @@ internal void AddPendingSceneRemoval(string sceneGUID) { if (m_PendingScenesToBeLoaded.ContainsKey(sceneGUID)) m_PendingScenesToBeLoaded.Remove(sceneGUID); - if (m_ActiveScenes.Contains(sceneGUID)) + if (m_ActiveScenes.Contains(sceneGUID) && m_CurrentBakingSet != null) m_PendingScenesToBeUnloaded.TryAdd(sceneGUID, m_CurrentBakingSet.GetSceneCellIndexList(sceneGUID)); } @@ -1546,6 +1546,7 @@ static internal int GetNumberOfBricksAtSubdiv(IndirectionEntryInfo entryInfo) /// public void PerformPendingOperations() { + #if UNITY_EDITOR checksDuringBakeAction?.Invoke(); #endif diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumePerSceneData.cs b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumePerSceneData.cs index a1132b5ce2e..639f3087436 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumePerSceneData.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumePerSceneData.cs @@ -76,6 +76,13 @@ internal void QueueSceneLoading() if (serializedBakingSet == null) return; + #if UNITY_EDITOR + // Check if we are trying to load APV data for a scene which has not enabled APV (or it was removed) + var bakedData = serializedBakingSet.GetSceneBakeData(sceneGUID); + if (bakedData != null && bakedData.hasProbeVolume == false) + return; + #endif + var refVol = ProbeReferenceVolume.instance; refVol.AddPendingSceneLoading(sceneGUID, serializedBakingSet); } diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeScratchBufferPool.cs b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeScratchBufferPool.cs index bdee7c19097..f5404a10aec 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeScratchBufferPool.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeScratchBufferPool.cs @@ -232,6 +232,12 @@ public bool AllocateScratchBuffer(int chunkCount, out CellStreamingScratchBuffer public void ReleaseScratchBuffer(CellStreamingScratchBuffer scratchBuffer) { + if (scratchBuffer.chunkSize != chunkSize) + { + scratchBuffer.Dispose(); + return; + } + s_ChunkCount = scratchBuffer.chunkCount; var pool = m_Pools.Find((o) => o.chunkCount == s_ChunkCount); Debug.Assert(pool != null); diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs b/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs index 70a4d89d30d..a1538fbdef8 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs @@ -164,6 +164,17 @@ internal static void FindParameters(object o, List parameters, if (filter?.Invoke(field) ?? true) { VolumeParameter volumeParameter = (VolumeParameter)field.GetValue(o); +#if UNITY_EDITOR || DEVELOPMENT_BUILD + var attr = (DisplayInfoAttribute[])field.GetCustomAttributes(typeof(DisplayInfoAttribute), true); + if (attr.Length != 0) + { + volumeParameter.debugId = attr[0].name; + } + else + { + volumeParameter.debugId = field.Name; + } +#endif parameters.Add(volumeParameter); } } diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeParameter.cs b/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeParameter.cs index 110e5c7e338..b8fc6b90d2b 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeParameter.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeParameter.cs @@ -18,6 +18,10 @@ namespace UnityEngine.Rendering /// public abstract class VolumeParameter : ICloneable { +#if UNITY_EDITOR || DEVELOPMENT_BUILD + internal string debugId { get; set; } +#endif + /// /// A beautified string for debugger output. This is set on a DebuggerDisplay on every /// parameter types. diff --git a/Packages/com.unity.render-pipelines.core/ShaderLibrary/Shadow/ShadowSamplingTent.hlsl b/Packages/com.unity.render-pipelines.core/ShaderLibrary/Shadow/ShadowSamplingTent.hlsl index 507635aaffe..53ad393b7f1 100644 --- a/Packages/com.unity.render-pipelines.core/ShaderLibrary/Shadow/ShadowSamplingTent.hlsl +++ b/Packages/com.unity.render-pipelines.core/ShaderLibrary/Shadow/ShadowSamplingTent.hlsl @@ -1,5 +1,6 @@ #ifndef SHADOW_SAMPLING_TENT_INCLUDED #define SHADOW_SAMPLING_TENT_INCLUDED + // ------------------------------------------------------------------ // PCF Filtering Tent Functions // ------------------------------------------------------------------ @@ -140,108 +141,121 @@ void SampleShadow_ComputeSamples_Tent_3x3(real4 shadowMapTexture_TexelSize, real } // 5x5 Tent filter (45 degree sloped triangles in U and V) +#define SampleShadow_ComputeSamples_Tent_Filter_5x5(Type, shadowMapTexelSize, coord, fetchesWeights, fetchesUV) \ +{ \ + /* Tent base is 5x5 base thus covering from 25 to 36 texels, thus we need 9 bilinear PCF fetches */ \ + Type##2 tentCenterInTexelSpace = (coord).xy * (shadowMapTexelSize).zw; \ + Type##2 centerOfFetchesInTexelSpace = floor(tentCenterInTexelSpace + 0.5); \ + Type##2 offsetFromTentCenterToCenterOfFetches = tentCenterInTexelSpace - centerOfFetchesInTexelSpace; \ + \ + /* Find the weight of each texel based on the area of a 45-degree sloped tent above each of them */ \ + Type##3 texelsWeightsU_A, texelsWeightsU_B; \ + Type##3 texelsWeightsV_A, texelsWeightsV_B; \ + SampleShadow_GetTexelWeights_Tent_5x5(offsetFromTentCenterToCenterOfFetches.x, texelsWeightsU_A, texelsWeightsU_B); \ + SampleShadow_GetTexelWeights_Tent_5x5(offsetFromTentCenterToCenterOfFetches.y, texelsWeightsV_A, texelsWeightsV_B); \ + \ + /* Each fetch will cover a group of 2x2 texels, the weight of each group is the sum of the weights of the texels */ \ + Type##3 fetchesWeightsU = Type##3(texelsWeightsU_A.xz, texelsWeightsU_B.y) + Type##3(texelsWeightsU_A.y, texelsWeightsU_B.xz); \ + Type##3 fetchesWeightsV = Type##3(texelsWeightsV_A.xz, texelsWeightsV_B.y) + Type##3(texelsWeightsV_A.y, texelsWeightsV_B.xz); \ + \ + /* Move the PCF bilinear fetches to respect texels weights */ \ + Type##3 fetchesOffsetsU = Type##3(texelsWeightsU_A.y, texelsWeightsU_B.xz) / fetchesWeightsU.xyz + Type##3(-2.5, -0.5, 1.5); \ + Type##3 fetchesOffsetsV = Type##3(texelsWeightsV_A.y, texelsWeightsV_B.xz) / fetchesWeightsV.xyz + Type##3(-2.5, -0.5, 1.5); \ + fetchesOffsetsU *= (shadowMapTexelSize).xxx; \ + fetchesOffsetsV *= (shadowMapTexelSize).yyy; \ + \ + Type##2 bilinearFetchOrigin = centerOfFetchesInTexelSpace * (shadowMapTexelSize).xy; \ + (fetchesUV)[0] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.x, fetchesOffsetsV.x); \ + (fetchesUV)[1] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.y, fetchesOffsetsV.x); \ + (fetchesUV)[2] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.z, fetchesOffsetsV.x); \ + (fetchesUV)[3] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.x, fetchesOffsetsV.y); \ + (fetchesUV)[4] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.y, fetchesOffsetsV.y); \ + (fetchesUV)[5] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.z, fetchesOffsetsV.y); \ + (fetchesUV)[6] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.x, fetchesOffsetsV.z); \ + (fetchesUV)[7] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.y, fetchesOffsetsV.z); \ + (fetchesUV)[8] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.z, fetchesOffsetsV.z); \ + \ + (fetchesWeights)[0] = fetchesWeightsU.x * fetchesWeightsV.x; \ + (fetchesWeights)[1] = fetchesWeightsU.y * fetchesWeightsV.x; \ + (fetchesWeights)[2] = fetchesWeightsU.z * fetchesWeightsV.x; \ + (fetchesWeights)[3] = fetchesWeightsU.x * fetchesWeightsV.y; \ + (fetchesWeights)[4] = fetchesWeightsU.y * fetchesWeightsV.y; \ + (fetchesWeights)[5] = fetchesWeightsU.z * fetchesWeightsV.y; \ + (fetchesWeights)[6] = fetchesWeightsU.x * fetchesWeightsV.z; \ + (fetchesWeights)[7] = fetchesWeightsU.y * fetchesWeightsV.z; \ + (fetchesWeights)[8] = fetchesWeightsU.z * fetchesWeightsV.z; \ +} + void SampleShadow_ComputeSamples_Tent_5x5(real4 shadowMapTexture_TexelSize, real2 coord, out real fetchesWeights[9], out real2 fetchesUV[9]) { - // tent base is 5x5 base thus covering from 25 to 36 texels, thus we need 9 bilinear PCF fetches - real2 tentCenterInTexelSpace = coord.xy * shadowMapTexture_TexelSize.zw; - real2 centerOfFetchesInTexelSpace = floor(tentCenterInTexelSpace + 0.5); - real2 offsetFromTentCenterToCenterOfFetches = tentCenterInTexelSpace - centerOfFetchesInTexelSpace; + SampleShadow_ComputeSamples_Tent_Filter_5x5(real, shadowMapTexture_TexelSize, coord, fetchesWeights, fetchesUV); +} - // find the weight of each texel based on the area of a 45 degree slop tent above each of them. - real3 texelsWeightsU_A, texelsWeightsU_B; - real3 texelsWeightsV_A, texelsWeightsV_B; - SampleShadow_GetTexelWeights_Tent_5x5(offsetFromTentCenterToCenterOfFetches.x, texelsWeightsU_A, texelsWeightsU_B); - SampleShadow_GetTexelWeights_Tent_5x5(offsetFromTentCenterToCenterOfFetches.y, texelsWeightsV_A, texelsWeightsV_B); - // each fetch will cover a group of 2x2 texels, the weight of each group is the sum of the weights of the texels - real3 fetchesWeightsU = real3(texelsWeightsU_A.xz, texelsWeightsU_B.y) + real3(texelsWeightsU_A.y, texelsWeightsU_B.xz); - real3 fetchesWeightsV = real3(texelsWeightsV_A.xz, texelsWeightsV_B.y) + real3(texelsWeightsV_A.y, texelsWeightsV_B.xz); +// 7x7 Tent filter (45 degree sloped triangles in U and V) +#define SampleShadow_ComputeSamples_Tent_Filter_7x7(Type, shadowMapTexelSize, coord, fetchesWeights, fetchesUV) \ +{ \ + /* Tent base is 7x7 base thus covering from 49 to 64 texels, thus we need 16 bilinear PCF fetches */ \ + Type##2 tentCenterInTexelSpace = (coord).xy * (shadowMapTexelSize).zw; \ + Type##2 centerOfFetchesInTexelSpace = floor(tentCenterInTexelSpace + 0.5); \ + Type##2 offsetFromTentCenterToCenterOfFetches = tentCenterInTexelSpace - centerOfFetchesInTexelSpace; \ + \ + /* Find the weight of each texel based on the area of a 45 degree slop tent above each of them. */ \ + Type##4 texelsWeightsU_A, texelsWeightsU_B; \ + Type##4 texelsWeightsV_A, texelsWeightsV_B; \ + SampleShadow_GetTexelWeights_Tent_7x7(offsetFromTentCenterToCenterOfFetches.x, texelsWeightsU_A, texelsWeightsU_B); \ + SampleShadow_GetTexelWeights_Tent_7x7(offsetFromTentCenterToCenterOfFetches.y, texelsWeightsV_A, texelsWeightsV_B); \ + \ + /* Each fetch will cover a group of 2x2 texels, the weight of each group is the sum of the weights of the texels */ \ + Type##4 fetchesWeightsU = Type##4(texelsWeightsU_A.xz, texelsWeightsU_B.xz) + Type##4(texelsWeightsU_A.yw, texelsWeightsU_B.yw); \ + Type##4 fetchesWeightsV = Type##4(texelsWeightsV_A.xz, texelsWeightsV_B.xz) + Type##4(texelsWeightsV_A.yw, texelsWeightsV_B.yw); \ + \ + /* Move the PCF bilinear fetches to respect texels weights */ \ + Type##4 fetchesOffsetsU = Type##4(texelsWeightsU_A.yw, texelsWeightsU_B.yw) / fetchesWeightsU.xyzw + Type##4(-3.5, -1.5, 0.5, 2.5); \ + Type##4 fetchesOffsetsV = Type##4(texelsWeightsV_A.yw, texelsWeightsV_B.yw) / fetchesWeightsV.xyzw + Type##4(-3.5, -1.5, 0.5, 2.5); \ + fetchesOffsetsU *= (shadowMapTexelSize).xxxx; \ + fetchesOffsetsV *= (shadowMapTexelSize).yyyy; \ + \ + Type##2 bilinearFetchOrigin = centerOfFetchesInTexelSpace * (shadowMapTexelSize).xy; \ + (fetchesUV)[0] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.x, fetchesOffsetsV.x); \ + (fetchesUV)[1] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.y, fetchesOffsetsV.x); \ + (fetchesUV)[2] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.z, fetchesOffsetsV.x); \ + (fetchesUV)[3] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.w, fetchesOffsetsV.x); \ + (fetchesUV)[4] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.x, fetchesOffsetsV.y); \ + (fetchesUV)[5] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.y, fetchesOffsetsV.y); \ + (fetchesUV)[6] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.z, fetchesOffsetsV.y); \ + (fetchesUV)[7] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.w, fetchesOffsetsV.y); \ + (fetchesUV)[8] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.x, fetchesOffsetsV.z); \ + (fetchesUV)[9] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.y, fetchesOffsetsV.z); \ + (fetchesUV)[10] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.z, fetchesOffsetsV.z); \ + (fetchesUV)[11] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.w, fetchesOffsetsV.z); \ + (fetchesUV)[12] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.x, fetchesOffsetsV.w); \ + (fetchesUV)[13] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.y, fetchesOffsetsV.w); \ + (fetchesUV)[14] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.z, fetchesOffsetsV.w); \ + (fetchesUV)[15] = bilinearFetchOrigin + Type##2(fetchesOffsetsU.w, fetchesOffsetsV.w); \ + \ + (fetchesWeights)[0] = fetchesWeightsU.x * fetchesWeightsV.x; \ + (fetchesWeights)[1] = fetchesWeightsU.y * fetchesWeightsV.x; \ + (fetchesWeights)[2] = fetchesWeightsU.z * fetchesWeightsV.x; \ + (fetchesWeights)[3] = fetchesWeightsU.w * fetchesWeightsV.x; \ + (fetchesWeights)[4] = fetchesWeightsU.x * fetchesWeightsV.y; \ + (fetchesWeights)[5] = fetchesWeightsU.y * fetchesWeightsV.y; \ + (fetchesWeights)[6] = fetchesWeightsU.z * fetchesWeightsV.y; \ + (fetchesWeights)[7] = fetchesWeightsU.w * fetchesWeightsV.y; \ + (fetchesWeights)[8] = fetchesWeightsU.x * fetchesWeightsV.z; \ + (fetchesWeights)[9] = fetchesWeightsU.y * fetchesWeightsV.z; \ + (fetchesWeights)[10] = fetchesWeightsU.z * fetchesWeightsV.z; \ + (fetchesWeights)[11] = fetchesWeightsU.w * fetchesWeightsV.z; \ + (fetchesWeights)[12] = fetchesWeightsU.x * fetchesWeightsV.w; \ + (fetchesWeights)[13] = fetchesWeightsU.y * fetchesWeightsV.w; \ + (fetchesWeights)[14] = fetchesWeightsU.z * fetchesWeightsV.w; \ + (fetchesWeights)[15] = fetchesWeightsU.w * fetchesWeightsV.w; \ +} - // move the PCF bilinear fetches to respect texels weights - real3 fetchesOffsetsU = real3(texelsWeightsU_A.y, texelsWeightsU_B.xz) / fetchesWeightsU.xyz + real3(-2.5,-0.5,1.5); - real3 fetchesOffsetsV = real3(texelsWeightsV_A.y, texelsWeightsV_B.xz) / fetchesWeightsV.xyz + real3(-2.5,-0.5,1.5); - fetchesOffsetsU *= shadowMapTexture_TexelSize.xxx; - fetchesOffsetsV *= shadowMapTexture_TexelSize.yyy; - real2 bilinearFetchOrigin = centerOfFetchesInTexelSpace * shadowMapTexture_TexelSize.xy; - fetchesUV[0] = bilinearFetchOrigin + real2(fetchesOffsetsU.x, fetchesOffsetsV.x); - fetchesUV[1] = bilinearFetchOrigin + real2(fetchesOffsetsU.y, fetchesOffsetsV.x); - fetchesUV[2] = bilinearFetchOrigin + real2(fetchesOffsetsU.z, fetchesOffsetsV.x); - fetchesUV[3] = bilinearFetchOrigin + real2(fetchesOffsetsU.x, fetchesOffsetsV.y); - fetchesUV[4] = bilinearFetchOrigin + real2(fetchesOffsetsU.y, fetchesOffsetsV.y); - fetchesUV[5] = bilinearFetchOrigin + real2(fetchesOffsetsU.z, fetchesOffsetsV.y); - fetchesUV[6] = bilinearFetchOrigin + real2(fetchesOffsetsU.x, fetchesOffsetsV.z); - fetchesUV[7] = bilinearFetchOrigin + real2(fetchesOffsetsU.y, fetchesOffsetsV.z); - fetchesUV[8] = bilinearFetchOrigin + real2(fetchesOffsetsU.z, fetchesOffsetsV.z); - fetchesWeights[0] = fetchesWeightsU.x * fetchesWeightsV.x; - fetchesWeights[1] = fetchesWeightsU.y * fetchesWeightsV.x; - fetchesWeights[2] = fetchesWeightsU.z * fetchesWeightsV.x; - fetchesWeights[3] = fetchesWeightsU.x * fetchesWeightsV.y; - fetchesWeights[4] = fetchesWeightsU.y * fetchesWeightsV.y; - fetchesWeights[5] = fetchesWeightsU.z * fetchesWeightsV.y; - fetchesWeights[6] = fetchesWeightsU.x * fetchesWeightsV.z; - fetchesWeights[7] = fetchesWeightsU.y * fetchesWeightsV.z; - fetchesWeights[8] = fetchesWeightsU.z * fetchesWeightsV.z; -} - -// 7x7 Tent filter (45 degree sloped triangles in U and V) void SampleShadow_ComputeSamples_Tent_7x7(real4 shadowMapTexture_TexelSize, real2 coord, out real fetchesWeights[16], out real2 fetchesUV[16]) { - // tent base is 7x7 base thus covering from 49 to 64 texels, thus we need 16 bilinear PCF fetches - real2 tentCenterInTexelSpace = coord.xy * shadowMapTexture_TexelSize.zw; - real2 centerOfFetchesInTexelSpace = floor(tentCenterInTexelSpace + 0.5); - real2 offsetFromTentCenterToCenterOfFetches = tentCenterInTexelSpace - centerOfFetchesInTexelSpace; - - // find the weight of each texel based on the area of a 45 degree slop tent above each of them. - real4 texelsWeightsU_A, texelsWeightsU_B; - real4 texelsWeightsV_A, texelsWeightsV_B; - SampleShadow_GetTexelWeights_Tent_7x7(offsetFromTentCenterToCenterOfFetches.x, texelsWeightsU_A, texelsWeightsU_B); - SampleShadow_GetTexelWeights_Tent_7x7(offsetFromTentCenterToCenterOfFetches.y, texelsWeightsV_A, texelsWeightsV_B); - - // each fetch will cover a group of 2x2 texels, the weight of each group is the sum of the weights of the texels - real4 fetchesWeightsU = real4(texelsWeightsU_A.xz, texelsWeightsU_B.xz) + real4(texelsWeightsU_A.yw, texelsWeightsU_B.yw); - real4 fetchesWeightsV = real4(texelsWeightsV_A.xz, texelsWeightsV_B.xz) + real4(texelsWeightsV_A.yw, texelsWeightsV_B.yw); - - // move the PCF bilinear fetches to respect texels weights - real4 fetchesOffsetsU = real4(texelsWeightsU_A.yw, texelsWeightsU_B.yw) / fetchesWeightsU.xyzw + real4(-3.5,-1.5,0.5,2.5); - real4 fetchesOffsetsV = real4(texelsWeightsV_A.yw, texelsWeightsV_B.yw) / fetchesWeightsV.xyzw + real4(-3.5,-1.5,0.5,2.5); - fetchesOffsetsU *= shadowMapTexture_TexelSize.xxxx; - fetchesOffsetsV *= shadowMapTexture_TexelSize.yyyy; - - real2 bilinearFetchOrigin = centerOfFetchesInTexelSpace * shadowMapTexture_TexelSize.xy; - fetchesUV[0] = bilinearFetchOrigin + real2(fetchesOffsetsU.x, fetchesOffsetsV.x); - fetchesUV[1] = bilinearFetchOrigin + real2(fetchesOffsetsU.y, fetchesOffsetsV.x); - fetchesUV[2] = bilinearFetchOrigin + real2(fetchesOffsetsU.z, fetchesOffsetsV.x); - fetchesUV[3] = bilinearFetchOrigin + real2(fetchesOffsetsU.w, fetchesOffsetsV.x); - fetchesUV[4] = bilinearFetchOrigin + real2(fetchesOffsetsU.x, fetchesOffsetsV.y); - fetchesUV[5] = bilinearFetchOrigin + real2(fetchesOffsetsU.y, fetchesOffsetsV.y); - fetchesUV[6] = bilinearFetchOrigin + real2(fetchesOffsetsU.z, fetchesOffsetsV.y); - fetchesUV[7] = bilinearFetchOrigin + real2(fetchesOffsetsU.w, fetchesOffsetsV.y); - fetchesUV[8] = bilinearFetchOrigin + real2(fetchesOffsetsU.x, fetchesOffsetsV.z); - fetchesUV[9] = bilinearFetchOrigin + real2(fetchesOffsetsU.y, fetchesOffsetsV.z); - fetchesUV[10] = bilinearFetchOrigin + real2(fetchesOffsetsU.z, fetchesOffsetsV.z); - fetchesUV[11] = bilinearFetchOrigin + real2(fetchesOffsetsU.w, fetchesOffsetsV.z); - fetchesUV[12] = bilinearFetchOrigin + real2(fetchesOffsetsU.x, fetchesOffsetsV.w); - fetchesUV[13] = bilinearFetchOrigin + real2(fetchesOffsetsU.y, fetchesOffsetsV.w); - fetchesUV[14] = bilinearFetchOrigin + real2(fetchesOffsetsU.z, fetchesOffsetsV.w); - fetchesUV[15] = bilinearFetchOrigin + real2(fetchesOffsetsU.w, fetchesOffsetsV.w); - - fetchesWeights[0] = fetchesWeightsU.x * fetchesWeightsV.x; - fetchesWeights[1] = fetchesWeightsU.y * fetchesWeightsV.x; - fetchesWeights[2] = fetchesWeightsU.z * fetchesWeightsV.x; - fetchesWeights[3] = fetchesWeightsU.w * fetchesWeightsV.x; - fetchesWeights[4] = fetchesWeightsU.x * fetchesWeightsV.y; - fetchesWeights[5] = fetchesWeightsU.y * fetchesWeightsV.y; - fetchesWeights[6] = fetchesWeightsU.z * fetchesWeightsV.y; - fetchesWeights[7] = fetchesWeightsU.w * fetchesWeightsV.y; - fetchesWeights[8] = fetchesWeightsU.x * fetchesWeightsV.z; - fetchesWeights[9] = fetchesWeightsU.y * fetchesWeightsV.z; - fetchesWeights[10] = fetchesWeightsU.z * fetchesWeightsV.z; - fetchesWeights[11] = fetchesWeightsU.w * fetchesWeightsV.z; - fetchesWeights[12] = fetchesWeightsU.x * fetchesWeightsV.w; - fetchesWeights[13] = fetchesWeightsU.y * fetchesWeightsV.w; - fetchesWeights[14] = fetchesWeightsU.z * fetchesWeightsV.w; - fetchesWeights[15] = fetchesWeightsU.w * fetchesWeightsV.w; + SampleShadow_ComputeSamples_Tent_Filter_7x7(real, shadowMapTexture_TexelSize, coord, fetchesWeights, fetchesUV); } #endif diff --git a/Packages/com.unity.render-pipelines.core/Tests/Editor/RenderGraphViewerTests.cs b/Packages/com.unity.render-pipelines.core/Tests/Editor/RenderGraphViewerTests.cs index 1ee84a66c2e..ecfa37cebf8 100644 --- a/Packages/com.unity.render-pipelines.core/Tests/Editor/RenderGraphViewerTests.cs +++ b/Packages/com.unity.render-pipelines.core/Tests/Editor/RenderGraphViewerTests.cs @@ -25,7 +25,7 @@ static IEnumerable ScriptPathToAssetPathTestCases() // Script in project ( "Assets/File.cs", "Assets/File.cs" ), - // Script in package (this will work regardless of where the package is located, + // Script in package (this will work regardless of where the package is located, // i.e. in Library, embedded in Packages folder, via "file:" dependency or Git URL) ( $"{relativePackagePath}/File.cs".Replace(@"\", "/"), $"{packageInfo.assetPath}/File.cs" ), @@ -52,7 +52,7 @@ static IEnumerable ScriptPathToAssetPathTestCases() yield return new TestCaseData($"./{inputPath}".Replace("/", @"\"), expectedResult); // Absolute paths, Windows separators - yield return new TestCaseData($"{projectPath}/{inputPath}".Replace("/", @"\"), expectedResult); + yield return new TestCaseData($"{projectPath}/{inputPath}".Replace("/", @"\"), expectedResult); #endif } } diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/Frame-Settings.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/Frame-Settings.md index b9a32c34fa1..81fa4ca9387 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/Frame-Settings.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/Frame-Settings.md @@ -2,7 +2,7 @@ Frame Settings are settings HDRP uses to render Cameras, real-time, baked, and custom reflections. To find the right balance between render quality and runtime performance, adjust the Frame Settings for your [Cameras](hdrp-camera-component-reference.md) to enable or disable effects at runtime on a per-Camera basis. -You can set the default values for Frame Settings for each of these three individually from within the the [HDRP Graphics settings window](Default-Settings-Window.md). +You can set the default values for Frame Settings for each of these three individually from within the [HDRP Graphics settings window](Default-Settings-Window.md). To make Cameras and Reflection Probes use their respective default values for Frame Settings, disable the **Custom Frame Settings** checkbox under the **General** settings of Cameras or under **Capture Settings** of Reflection Probes. diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md index dab7fe67b66..a116d1f1508 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md @@ -54,23 +54,24 @@ These settings control the draw distance and resolution of the decals atlas that ### Dynamic Resolution | **Property** | **Description** | -| ------------------------------------------- | ------------------------------------------------------------ | +|---------------------------------------------|--------------------------------------------------------------| | **Enable** | Enable the checkbox to make HDRP support dynamic resolution in your Unity Project. | -| **- Enable DLSS** | Enable the checkbox to make HDRP support NVIDIA Deep Learning Super Sampling (DLSS).
This property only appears if you enable the NVIDIA package (com.unity.modules.nvidia) in your Unity project. | -| **-- Mode** | Use the drop-down to select which performance mode DLSS operates on. The options are:
• **Balanced**: - Balances performance with quality.
• **MaxPerf**: - Fast performance, lower quality.
• **MaxQuality**: - High quality, lower performance.
• **UltraPerformance**: - Fastest performance, lowest quality. | -| **-- Injection Point** | Use the drop-down to select at which point DLSS runs in the rendering pipeline:
• **Before Post**: - DLSS runs when all post processing effects are at full resolution.
• **After Depth Of Field**: - Depth of field runs at a low resolution and DLSS upscales everything in the next rendering step. All other post processing effects run at full resolution.
• **After Post Process**: - DLSS runs at the end of the pipeline when all post process are at low resolution.
• | +| **- Enable DLSS** | Enable the checkbox to make HDRP support NVIDIA Deep Learning Super Sampling (DLSS).
This property only appears if you enable the NVIDIA package (`com.unity.modules.nvidia`) in your Unity project. | +| **-- Mode** | Use the drop-down to select which performance mode DLSS operates on. The options are:
• **Balanced**: Balances performance with quality.
• **MaxPerf**: Fast performance, lower quality.
• **MaxQuality**: High quality, lower performance.
• **UltraPerformance**: Fastest performance, lowest quality. | +| **-- Injection Point** | Use the drop-down to select at which point DLSS runs in the rendering pipeline:
• **Before Post**: DLSS runs when all post-processing effects are at full resolution.
• **After Depth Of Field**: Depth of field runs at a low resolution, and DLSS upscales everything in the next rendering step. All other post-processing effects run at full resolution.
• **After Post Process**: DLSS runs at the end of the pipeline when all post-processes are at low resolution. | | **-- Use Optimal Settings** | Enable the checkbox to make DLSS control the Sharpness and Screen Percentage automatically. | | **-- Sharpness** | Controls how the DLSS upsampler renders edges on the image. More sharpness usually means more contrast and a clearer image but can increase flickering and fireflies. Unity ignores this property if you enable **Use Optimal Settings**. | -| **- Dynamic Resolution Type** | Use the drop-down to select the type of dynamic resolution HDRP uses:
• **Software**: This option allocates render targets to accommodate the maximum resolution possible, then rescales the viewport accordingly. This allows the viewport to render at varying resolutions.
• **Hardware**: This option treats the render targets, up until the back buffer, as if they are all the scaled size. This means HDRP clears the render targets faster. | -| **- Upscale Filter** | Use the drop-down to select the filter that HDRP uses for upscaling (unless overridden by user via script). The options are:
• **Catmull-Rom**: A bicubic upsample with 4 taps.
• **Contrast Adaptive Sharpen**: An ultra sharp upsample. This option is not meant for screen percentages less than 50% and still sharpens when you set the screen percentage to 100%. It uses **FidelityFX (CAS) AMD™**.
• **FidelityFX Super Resolution 1.0 AMD™**: A spatial super-resolution technology that leverages cutting-edge algorithms to produce impressive upscaling quality at very fast performance.
• **TAA Upscale**: A temporal anti-aliasing upscaler that uses information from previous frames to produce high-quality visuals.
• **Spatial-Temporal Post-processing (STP)**: A low-overhead spatio-temporal anti-aliasing upscaler that attempts to produce sharp visuals at scaling factors as low as 50%. | -| **- Use Mip Bias** | Apply a negative bias on the texture samplers of deferred, opaque and transparent passes. This improves detail on textures but increases the texture fetching cost. Cost varies per platform. | +| **- Dynamic Resolution Type** | Use the drop-down to select the type of dynamic resolution HDRP uses:
• **Software**: Allocates render targets to accommodate the maximum resolution possible, then rescales the viewport accordingly. This allows the viewport to render at varying resolutions.
• **Hardware**: Treats the render targets, up until the back buffer, as if they are all the scaled size. This means HDRP clears the render targets faster. | +| **- Upscale Filter** | Use the drop-down to select the filter that HDRP uses for upscaling (unless overridden by user via script). The options are:
• **Catmull-Rom**: A bicubic upsample with 4 taps.
• **Contrast Adaptive Sharpen**: An ultra-sharp upsample. This option is not meant for screen percentages less than 50% and still sharpens when you set the screen percentage to 100%. It uses **FidelityFX (CAS) AMD™**.
• **FidelityFX Super Resolution 1.0 AMD™**: A spatial super-resolution technology that leverages cutting-edge algorithms to produce impressive upscaling quality at very fast performance.
• **TAA Upscale**: A temporal anti-aliasing upscaler that uses information from previous frames to produce high-quality visuals.
• **Spatial-Temporal Post-Processing (STP)**: A low-overhead spatio-temporal anti-aliasing upscaler that attempts to produce sharp visuals at scaling factors as low as 50%. | +| **- Use Mip Bias** | Apply a negative bias on the texture samplers of deferred, opaque, and transparent passes. This improves detail on textures but increases the texture fetching cost. Cost varies per platform. | | **- Minimum Screen Percentage** | The minimum screen percentage that dynamic resolution can reach. | | **- Maximum Screen Percentage** | The maximum screen percentage that dynamic resolution can reach. This value must be higher than the **Min Screen Percentage**. | | **- Force Screen Percentage** | Enable the checkbox to force HDRP to use a specific screen percentage for dynamic resolution. This feature is useful for debugging dynamic resolution. | -| **- Forced Screen Percentage** | The specific screen percentage that HDRP uses for dynamic resolution. This property is only visible when you enable the **Force Screen Percentage**.. | -| **- Low Res Transparency Min Threshold** | The minimum percentage threshold allowed to clamp low resolution transparency. When the resolution percentage falls below this threshold, HDRP will clamp the low resolution to this percentage. | +| **- Forced Screen Percentage** | The specific screen percentage that HDRP uses for dynamic resolution. This property is only visible when you enable the **Force Screen Percentage**. | +| **- Low Res Transparency Min Threshold** | The minimum percentage threshold allowed to clamp low-resolution transparency. When the resolution percentage falls below this threshold, HDRP will clamp the low resolution to this percentage. | | **- Ray Tracing Half Resolution Threshold** | The minimum percentage threshold allowed to render ray tracing effects at half resolution. When the resolution percentage falls below this threshold, HDRP will render ray tracing effects at full resolution. | + ## Compute Thickness diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/Menu-Items.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/Menu-Items.md index 033b60a08e0..0fbfa4cb7be 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/Menu-Items.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/Menu-Items.md @@ -21,6 +21,8 @@ This section includes all the menu items under the **Edit > Rendering > Renderin This section includes all the menu items under the **Edit > Rendering > Materials** menu fold-out. +For more information, refer to [Convert materials and shaders](convert-from-built-in-convert-materials-and-shaders.md). + | **Item** | **Description** | |-------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | **Generate Material Resources** | Generate look-up table resources for all HDRP Materials. The generated resources will be placed in the directory **Assets/HDRPDefaultResources/Generated**. | diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/Physical-Light-Units.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/Physical-Light-Units.md index fc75271c170..015b5a03685 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/Physical-Light-Units.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/Physical-Light-Units.md @@ -30,7 +30,7 @@ The unit of [illuminance](Glossary.md#Illuminance). A light source that emits 1 #### Nits (candela per square meter): -The unit of luminance. Describes the surface power of a visible light source. When you use this unit, the overall power of a light source depends the size of the light source, meaning the the illumination level of a Scene changes depending on the size of the light source. Highlights that a light source produces conserve their intensity regardless of the size of the surface. +The unit of luminance. Describes the surface power of a visible light source. When you use this unit, the overall power of a light source depends the size of the light source, meaning the illumination level of a Scene changes depending on the size of the light source. Highlights that a light source produces conserve their intensity regardless of the size of the surface. A light source that emits 1 candela of [luminous intensity](Glossary.md#LuminousIntensity) onto an area of 1 square meter has a luminance of 1 candela per square meter. diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/Planar-Reflection-Probe.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/Planar-Reflection-Probe.md index 2e644aa0907..d5b8fef13c8 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/Planar-Reflection-Probe.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/Planar-Reflection-Probe.md @@ -4,7 +4,7 @@ The Planar Reflection Probe component is one of the types of [Reflection Probe]( ## Properties -Planar Reflection Probes share many properties with the the [built-in render pipeline Reflection Probe](https://docs.unity3d.com/Manual/class-ReflectionProbe.html), and the [HDRP cubemap Reflection Probe](Reflection-Probe.md). +Planar Reflection Probes share many properties with the [built-in render pipeline Reflection Probe](https://docs.unity3d.com/Manual/class-ReflectionProbe.html), and the [HDRP cubemap Reflection Probe](Reflection-Probe.md). Planar Reflection Probes use the same texture format than the one selected in [HDRP Asset](HDRP-Asset.md) for Color Buffer Format. diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/SRPBatcher-Materials.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/SRPBatcher-Materials.md index 8350d44af94..32896e226ee 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/SRPBatcher-Materials.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/SRPBatcher-Materials.md @@ -14,7 +14,7 @@ A GameObject must meet the following requirements to be compatible with the SRP ## Shader compatibility -All lit and unlit shaders in the the Universal Render Pipeline (URP) and the High Definition Render Pipeline (HDRP) fit this requirement (except for the particle versions of these shaders). +All lit and unlit shaders in the Universal Render Pipeline (URP) and the High Definition Render Pipeline (HDRP) fit this requirement (except for the particle versions of these shaders). For a custom shader to be compatible with the SRP Batcher it must meet the following requirements: @@ -23,4 +23,4 @@ For a custom shader to be compatible with the SRP Batcher it must meet the follo You can check the compatibility status of a shader in the Inspector panel. -![You can check the compatibility of your shaders in the Inspector panel for the specific shader.](Images/SRP_batcher_shader_compatibility.png) \ No newline at end of file +![You can check the compatibility of your shaders in the Inspector panel for the specific shader.](Images/SRP_batcher_shader_compatibility.png) diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md index ac55f890ec5..8b57b7546f8 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md @@ -292,8 +292,8 @@ * [Create a custom Pass in a C# script](Custom-Pass-Scripting.md) * [Understand custom pass variables](AOVs.md) * [Manage a custom pass without a GameObject](Global-Custom-Pass-API.md) - * [Injection points](Custom-Pass-Injection-Points.md) - * [Customize the the High Definition Render Pipeline (HDRP)](render-graph.md) + * [Injection points](Custom-Pass-Injection-Points.md) + * [Customize the High Definition Render Pipeline (HDRP)](render-graph.md) * [Test and debug rendering and post-processing](rendering-troubleshoot.md) * [Troubleshoot a custom pass](Custom-Pass-Troubleshooting.md) * [View a custom pass in the Frame Debugger](Custom-Pass-Frame-Debugger.md) diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/batch-renderer-group-creating-draw-commands.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/batch-renderer-group-creating-draw-commands.md index 3d2fe8ed04d..5ddef7d1a61 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/batch-renderer-group-creating-draw-commands.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/batch-renderer-group-creating-draw-commands.md @@ -8,7 +8,7 @@ To create draw commands, use the [BatchRendererGroup.OnPerformCulling](https://d Your `OnPerformCulling` implementation can generate as many or as few draw commands as you want. A simple implementation that only uses a single mesh and material could only output a single draw command, a more complex implementation could output thousands, each with different meshes and materials. -**Note**: To provide maximum flexibility, Unity doesn't preallocate the arrays in the `BatchCullingOutputDrawCommands` output struct and stores them as raw pointers so you can easily allocate them and use them from [Burst](https://docs.unity3d.com/Packages/com.unity.burst@latest) jobs. You must allocate the arrays using [UnsafeUtility.Malloc](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Unity.Collections.LowLevel.Unsafe.UnsafeUtility.Malloc) with the the [Allocator.TempJob](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Unity.Collections.Allocator.TempJob) allocator. The callback shouldn't release the memory. Instead, Unity releases the memory after it finishes rendering using the draw commands. +**Note**: To provide maximum flexibility, Unity doesn't preallocate the arrays in the `BatchCullingOutputDrawCommands` output struct and stores them as raw pointers so you can easily allocate them and use them from [Burst](https://docs.unity3d.com/Packages/com.unity.burst@latest) jobs. You must allocate the arrays using [UnsafeUtility.Malloc](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Unity.Collections.LowLevel.Unsafe.UnsafeUtility.Malloc) with the [Allocator.TempJob](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Unity.Collections.Allocator.TempJob) allocator. The callback shouldn't release the memory. Instead, Unity releases the memory after it finishes rendering using the draw commands. See the following code sample for an example of how to create draw commands. This code sample builds on the one in [Creating batches](batch-renderer-group-creating-batches.md). @@ -256,4 +256,4 @@ public class SimpleBRGExample : MonoBehaviour } ``` -This is the final, complete, code sample for BRG. If you attach this Component to a GameObject, set a mesh and [DOTS Instancing](dots-instancing-shaders.md)-compatible material in the Inspector, and enter Play Mode, Unity renders three instances of the mesh using the material. \ No newline at end of file +This is the final, complete, code sample for BRG. If you attach this Component to a GameObject, set a mesh and [DOTS Instancing](dots-instancing-shaders.md)-compatible material in the Inspector, and enter Play Mode, Unity renders three instances of the mesh using the material. diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/convert-from-built-in-convert-materials-and-shaders.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/convert-from-built-in-convert-materials-and-shaders.md index fd855704ad6..1be9d338547 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/convert-from-built-in-convert-materials-and-shaders.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/convert-from-built-in-convert-materials-and-shaders.md @@ -14,6 +14,7 @@ To upgrade the Materials in your Scene to HDRP-compatible Materials: The automatic upgrade options described above can't upgrade all Materials to HDRP correctly: * You can't automatically upgrade custom Materials or Shaders to HDRP. You must [convert custom Materials and Shaders manually](#ManualConversion). +* HDRP can only convert materials from the **Assets** folder of your project. HDRP uses the [error shader](xref:shader-error) for GameObjects that use the default read-only material from the Built-In Render Pipeline, for example [primitives](xref:um-primitive-objects). * Height mapped Materials might look incorrect. This is because HDRP supports more height map displacement techniques and decompression options than the Built-in Render Pipeline. To upgrade a Material that uses a heightmap, modify the Material's **Amplitude** and **Base** properties until the result more closely matches the Built-in Render Pipeline version. * You can't upgrade particle shaders. HDRP doesn't support particle shaders, but it does provide Shader Graphs that are compatible with the [Built-in Particle System](https://docs.unity3d.com/Manual/Built-inParticleSystem.html). These Shader Graphs work in a similar way to the built-in particle shaders. To use these Shader Graphs, import the **Particle System Shader Samples** sample: diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/convert-project-from-built-in-render-pipeline.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/convert-project-from-built-in-render-pipeline.md index fb91338ace9..c1f0bf75e32 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/convert-project-from-built-in-render-pipeline.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/convert-project-from-built-in-render-pipeline.md @@ -5,6 +5,6 @@ The High Definition Render Pipeline (HDRP) uses a new set of shaders and lightin | Topic | Description | |-|-| | [Convert post-processing scripts](convert-from-built-in-convert-post-processing-scripts.md) | Remove the Post-Processing Version 2 package from a project and update your scripts to work with HDRP's own implementation for post processing. | -| [Convert lighting and shadows](convert-from-built-in-convert-lighting-and-shadows.md) | Convert a project to physical Light units to control the intensity of Lights, instead of the the arbitrary units the Built-in Render Pipeline uses. | +| [Convert lighting and shadows](convert-from-built-in-convert-lighting-and-shadows.md) | Convert a project to physical Light units to control the intensity of Lights, instead of the arbitrary units the Built-in Render Pipeline uses. | | [Convert materials and shaders](convert-from-built-in-convert-materials-and-shaders.md) | Upgrade the materials in your scene to HDRP-compatible materials, either automatically or manually. | | [Convert project with HDRP wizard](convert-from-built-in-convert-project-with-hdrp-wizard.md) | Add the HDRP package to a Built-in Render Pipeline project and set up HDRP. | diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/create-an-hdri-sky.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/create-an-hdri-sky.md index 1f3b7fc0124..7114b93b2da 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/create-an-hdri-sky.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/create-an-hdri-sky.md @@ -15,7 +15,7 @@ Tip: [Unity HDRI Pack](https://assetstore.unity.com/packages/essentials/beta-pro After you add an **HDRI Sky** override, you must set the Volume to use **HDRI Sky**. The [Visual Environment](visual-environment-volume-override-reference.md) override controls which type of sky the Volume uses. To set the Volume to use **HDRI Sky**: -1. In the **Visual Environment** override, go to the **Sky** > **Sky Type** +1. In the **Visual Environment** override, go to **Sky** > **Sky Type**. 2. Set **Sky Type** to **HDRI Sky**. HDRP now renders an **HDRI Sky** for any Camera this Volume affects. @@ -23,4 +23,3 @@ HDRP now renders an **HDRI Sky** for any Camera this Volume affects. Refer to the [HDRI Sky Volume Override Reference](hdri-sky-volume-override-reference.md) for more information. [!include[](snippets/volume-override-api.md)] - diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/custom-pass-reference.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/custom-pass-reference.md index 8d13c48af61..655306dcae3 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/custom-pass-reference.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/custom-pass-reference.md @@ -35,7 +35,7 @@ Configure a draw renderers Custom Pass in the **Custom Passes** panel using the | Target Depth Buffer | | | The target buffer where Unity writes and tests the depth and stencil data:

•**Camera:** Targets the current camera depth buffer that renders the Custom Pass.
•**Custom:** Uses the Custom Pass buffer allocated in the HDRP Asset.
•**None:** Doesn’t write the data to a buffer.

This buffer does not contain transparent objects that have **Depth Write** enabled in the [shader properties](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@10.2/manual/Lit-Shader.html). | | Clear Flags | | | Discards the contents of a buffer before Unity executes this Custom Pass.
Assign a clear flag to one of the following buffers:

•**None:** Doesn’t clear any buffers in this pass.
•**Color:** Clears the depth buffer.
•**Depth:** Clears the depth buffer and the stencil buffer.
•**All:** Clears the data in the color, depth and stencil buffers. | | Filters | | | Properties in this section determine the GameObjects that Unity renders in this Custom Pass. | -| | Queue | | Determines the kind of materials that this Custom Pass renders:
•**Opaque No Alpha test**: Opaque GameObjects without alpha test only.
•**Opaque Alpha Test: **Opaque GameObjects with alpha test only.
•**All Opaque**: All opaque GameObjects.
•**After Post Process Opaque**: Opaque GameObjects that use the after post process render pass.
•**Pre Refraction**: Transparent GameObjects that use the the pre refraction render pass.
•**Transparent**: Transparent GameObjects that use the default render pass.
•**Low Transparent**: Transparent GameObjects that use the low resolution render pass.
•**All Transparent**: All Transparent GameObjects.
•**All Transparent With Low Res**: Transparent GameObjects that use the Pre-refraction, Default, or Low resolution render pass.
•**After Post Process Transparent**: Transparent GameObjects that use after post process render pass.
•**Overlay**: All GameObjects that use the overlay render pass.
•**All:** All GameObjects. | +| | Queue | | Determines the kind of materials that this Custom Pass renders:
•**Opaque No Alpha test**: Opaque GameObjects without alpha test only.
•**Opaque Alpha Test: **Opaque GameObjects with alpha test only.
•**All Opaque**: All opaque GameObjects.
•**After Post Process Opaque**: Opaque GameObjects that use the after post process render pass.
•**Pre Refraction**: Transparent GameObjects that use the pre refraction render pass.
•**Transparent**: Transparent GameObjects that use the default render pass.
•**Low Transparent**: Transparent GameObjects that use the low resolution render pass.
•**All Transparent**: All Transparent GameObjects.
•**All Transparent With Low Res**: Transparent GameObjects that use the Pre-refraction, Default, or Low resolution render pass.
•**After Post Process Transparent**: Transparent GameObjects that use after post process render pass.
•**Overlay**: All GameObjects that use the overlay render pass.
•**All:** All GameObjects. | | | Layer Mask | | Determines the GameObject layer that this Custom Pass applies to. | | Overrides | | | | | | Override Mode | | Determines what this Custom Pass volume uses to render GameObjects included in this Custom Pass:
•**Material**
•**Shader**
•**Pass Name** | diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/custom-post-processing-dynamic-resolution-dlss.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/custom-post-processing-dynamic-resolution-dlss.md index b5ef01a2f7b..28ed1b6f885 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/custom-post-processing-dynamic-resolution-dlss.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/custom-post-processing-dynamic-resolution-dlss.md @@ -3,7 +3,7 @@ If you want to use DLSS or dynamic resolution with a custom post-processing pass, and need to interpolate or sample UVs from color, normal, or velocity, use the following functions to calculate the correct UVs: ```glsl -#include "Packages/com.unity.render-pipelines.high-dynamic/Runtime/ShaderLibrary/ShaderVariables.hlsl" +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl" //... diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/dots-instancing-shaders-access.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/dots-instancing-shaders-access.md index b53992bda2d..81e2327f32e 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/dots-instancing-shaders-access.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/dots-instancing-shaders-access.md @@ -6,6 +6,6 @@ To access DOTS Instanced properties, your shader can use one of the access macro * If the most significant bit of the metadata value is `0`, every instance uses the value from instance index zero. This means each instance loads directly from the byte address in the metadata value. In this case, the buffer only needs to store a single value, instead of one value per instance. * If the most significant bit of the metadata value is `1`, the address should contain an array where you can find the value for instance index `instanceID` using `AddressOfInstance0 + sizeof(PropertyType) * instanceID`. In this case, you should ensure that every rendered instance index has valid data in buffer. Otherwise, out-of-bounds access and undefined behavior can occur. -You can also set the the metadata value directly which is useful if you want to use a custom data source that doesn't use the above layout, such as a texture. +You can also set the metadata value directly which is useful if you want to use a custom data source that doesn't use the above layout, such as a texture. For an example of how to use these macros, see [Access macro example](dots-instancing-shaders-samples.md). diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/dots-instancing-shaders-macros.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/dots-instancing-shaders-macros.md index a57bb62925f..59fcb9f6f61 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/dots-instancing-shaders-macros.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/dots-instancing-shaders-macros.md @@ -4,7 +4,7 @@ Unity provides the following access macros: | **Access macro** | **Description** | | ------------------------------------------------------------ | ------------------------------------------------------------ | -| `UNITY_ACCESS_DOTS_INSTANCED_PROP(PropertyType, PropertyName)` | Returns the value loaded from `unity_DOTSInstanceData` using the layout described above. Shaders that Unity provides use this version for DOTS Instanced built-in properties that don’t have a default value to fall back on. | +| `UNITY_ACCESS_DOTS_INSTANCED_PROP(PropertyType, PropertyName)` | Returns the value loaded from `unity_DOTSInstanceData`. Refer to [Declare DOTS Instancing properties in a custom shader](dots-instancing-shaders-declare) for more information. Shaders that Unity provides use this version for DOTS Instanced built-in properties that don’t have a default value to fall back on. | | `UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(PropertyType, PropertyName)` | Returns the same as `UNITY_ACCESS_DOTS_INSTANCED_PROP`, except if the most significant bit of the metadata value is zero, it returns a default value. The default value is the value of the regular material property with the same name as the DOTS Instanced property, which is why Shaders that Unity provides use the convention where DOTS Instanced properties have the same name as regular material properties. When using the default value, the access macro doesn't access `unity_DOTSInstanceData` at all. Shaders that Unity provides use this access macro for DOTS Instanced material properties, so the loads fall back to the value set on the material. | | `UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_CUSTOM_DEFAULT(PropertyType, PropertyName, DefaultValue)` | Returns the same as `UNITY_ACCESS_DOTS_INSTANCED_PROP` unless the most significant bit of the metadata value is zero, in which case this macroreturns `DefaultValue` instead, and doesn't access `unity_DOTSInstanceData`. | | `UNITY_DOTS_INSTANCED_METADATA_NAME(PropertyType, PropertyName)` | Returns the metadata value directly without accessing anything. This is useful for custom instance data loading schemes. | diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/hdri-sky-volume-override-reference.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/hdri-sky-volume-override-reference.md index 0f20a632f1f..d96406ed937 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/hdri-sky-volume-override-reference.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/hdri-sky-volume-override-reference.md @@ -1,6 +1,6 @@ # HDRI Sky Volume Override reference -The HDRI Sky Volume Override component exposes options that you can use to define how the High Definition Render Pipeline (HDRP) renders an HDRI sky. +The HDRI Sky Volume Override component provides options to define how the High Definition Render Pipeline (HDRP) renders an HDRI sky. Refer to [Create an HDRI sky](create-an-HDRI-sky.md) for more information. @@ -22,51 +22,52 @@ Refer to [Create an HDRI sky](create-an-HDRI-sky.md) for more information. HDRI Sky - Assign a HDRI Texture that HDRP uses to render the sky. + Assign an HDRI texture to render the sky in HDRP. Distortion Mode - Use the drop-down to select the method that HDRP uses to calculate the sky distortion.
None: No distortion.
Procedural: HDRP distorts the sky using a uniform wind direction.
Flowmap: HDRP distorts the sky with a user provided flowmap. + Select how HDRP calculates sky distortion:
None: No distortion.
Procedural: Distorts the sky using uniform wind direction.
Flowmap: Uses a user-provided flowmap for distortion. Orientation - The orientation of the distortion relative to the X world vector (in degrees).
This value can be relative to the Global Wind Orientation defined in the Visual Environment. + Set the distortion orientation relative to the X-world vector (degrees).
This can be relative to the Global Wind Orientation in the Visual Environment. Speed - The speed at which HDRP scrolls the distortion texture.
This value can be relative to the Global Wind Speed defined in the Visual Environment. + Define how fast HDRP scrolls the distortion texture.
This value can be relative to the Global Wind Speed defined in the Visual Environment. Flowmap - Assign a flowmap, in LatLong layout, that HDRP uses to distort UVs when rendering the sky.
This property only appears when you select Flowmap from the Distortion Mode drop-down. + Assign a LatLong flowmap for sky UV distortion.
Visible only when you select Flowmap from the Distortion Mode drop-down. Upper Hemisphere Only - Check the box if the flowmap contains distortion for the sky above the horizon only.
This property only appears when you select Flowmap from the Distortion Mode drop-down. + Enable if the flowmap distorts only the sky above the horizon.
Visible only when you select Flowmap from the Distortion Mode drop-down. Intensity Mode - Use the drop-down to select the method that HDRP uses to calculate the sky intensity.
Exposure: HDRP calculates intensity from an exposure value in EV100.
Multiplier: HDRP calculates intensity from a flat multiplier.
Lux: HDRP calculates intensity in terms of a target Lux value. + Choose how HDRP calculates sky intensity:
Exposure: Based on EV100 exposure.
Multiplier: Applies a flat multiplier.
Lux: Targets a specific Lux value. Exposure - Set the amount of light per unit area that HDRP applies to the HDRI Sky cubemap.
This property only appears when you select Exposure from the Intensity Mode drop-down. + Set the light per unit area applied to the HDRI Sky cubemap.
Visible only when you set Exposure in Intensity Mode from the Intensity Mode drop-down. Multiplier - Set the multiplier for HDRP to apply to the Scene as environmental light. HDRP multiplies the environment light in your Scene by this value.
This property only appears when you select Multiplier from the Intensity Mode drop-down. + Set a multiplier for environment light in the scene.
Visible only when you select Multiplier from the Intensity Mode drop-down. + Desired Lux Value - Set an absolute intensity for the HDR Texture you set in HDRI Sky, in Lux. This value represents the light received in a direction perpendicular to the ground. This is similar to the Lux unit you use to represent the Sun, so it's complimentary.
This property only appears when you select Lux from the Intensity Mode drop-down. + Set an absolute intensity for the HDR Texture you set in HDRI Sky, in Lux. This value represents the light received in a direction perpendicular to the ground. This is similar to the Lux unit you use to represent the Sun, so it's complimentary.
Visible only when you select Lux from the Intensity Mode drop-down. @@ -78,10 +79,10 @@ Refer to [Create an HDRI sky](create-an-HDRI-sky.md) for more information. Use the slider to set the angle to rotate the cubemap, in degrees. - + Lock Sun - Make the Sun rotate automatically when you move the HDRI Sky, and the HDRI Sky rotate automatically when you rotate the Sun. + Make the Sun rotate automatically when you move the HDRI Sky, and the HDRI Sky rotate automatically when you rotate the sun. Update Mode @@ -91,7 +92,7 @@ Refer to [Create an HDRI sky](create-an-HDRI-sky.md) for more information. Update Period - Set the period (in seconds) for HDRP to update the sky environment. Set the value to 0 if you want HDRP to update the sky environment every frame. This property only appears when you set the Update Mode to Realtime. + Set the update interval in seconds. Use 0 for per-frame updates. Visible only when you set the Update Mode to Realtime. @@ -116,19 +117,19 @@ These properties only appear if you enable [advanced properties](https://docs.un Backplate - Indicates whether to project the bottom part of the HDRI onto a plane with various shapes such as a Rectangle, Circle, Ellipse, or Infinite plane. + Projects the lower hemisphere of the HDRI onto a selected shape (Rectangle, Circle, Ellipse, or Infinite plane). Type - Specifies the shape of the backplate.

Disc: Projects the bottom of the HDRI texture onto a disc.

Rectangle: rojects the bottom of the HDRI texture onto a rectangle.

Ellipse: Projects the bottom of the HDRI texture onto an ellipse.

Infinite: Projects the bottom of the HDRI texture onto an infinite plane. + Specifies the shape of the backplate.

Disc: Projects the bottom of the HDRI texture onto a disc.

Rectangle: Projects the bottom of the HDRI texture onto a rectangle.

Ellipse: Projects the bottom of the HDRI texture onto an ellipse.

Infinite: Projects the bottom of the HDRI texture onto an infinite plane. Ground Level - The height of the ground level in the scene. + Specifies the height of the ground in the scene. @@ -140,25 +141,25 @@ These properties only appear if you enable [advanced properties](https://docs.un Projection - HDRP uses this number to control the projection of the bottom hemisphere of the HDRI on the backplate. Small projection distance implies higher pixels density with more distortion, large projection distance implies less pixels density with less distortion. + HDRP uses this number to control the projection of the bottom hemisphere of the HDRI on the backplate. Small projection distance implies higher pixel density with more distortion, large projection distance implies less pixel density with less distortion. Rotation - The rotation of the physical backplate. + Rotates the physical backplate. Texture Rotation - The rotation of the HDRI texture HDRP projects onto the backplate. + Rotates the HDRI texture projected onto the backplate. Texture Offset - The offset value to apply to the texture HDRP projects onto the backplate. + Offsets the texture projected onto the backplate. @@ -176,7 +177,7 @@ These properties only appear if you enable [advanced properties](https://docs.un Directional Shadow - Indicates whether the backplate receives shadows from the main directional Light. + Enables shadows from the main directional light on the backplate. @@ -201,4 +202,4 @@ These properties only appear if you enable [advanced properties](https://docs.un **Note**: To use ambient occlusion in the backplate, increase the value of the **Direct Lighting Strength** property on the [Ambient Occlusion](Override-Ambient-Occlusion.md) component override. As the backplate doesn't have global illumination, it can only get ambient occlusion from direct lighting. -**Limitation**: The backplate only appears in local reflection probes and it doesn't appear in the default sky reflection. This is because the default sky reflection is a cubemap projected at infinity which is incompatible with how Unity renders the backplate. +**Limitation**: The backplate only appears in local reflection probes and doesn't appear in the default sky reflection. This is because the default sky reflection is a cubemap projected at infinity which is incompatible with how Unity renders the backplate. diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/reference-path-tracing.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/reference-path-tracing.md index 0c1c65de963..fdb2786fdde 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/reference-path-tracing.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/reference-path-tracing.md @@ -12,7 +12,7 @@ | **Maximum Intensity** | Set a value to clamp the intensity of the light value each bounce returns. This avoids bright, isolated pixels in the final result.
**Note**: This property can make the final image dimmer, so if the result looks dark, increase the value of this property. | | **Sky Importance Sampling** | Set the sky sampling mode. Importance sampling favors the brightest directions, which is beneficial when using a sky model with high contrast and intense spots (like a sun, or street lights). On the other hand, it can be slightly detrimental when using a smooth, uniform sky. It's active by default for HDRI skies only, but can also be turned On and Off, regardless of the type of sky in use. | | **Seed Mode** | Set how the path tracer generates random numbers. The seed is the pattern the noise has. When accumulating samples, every frame needs a different seed. Otherwise, the same noisy image gets accumulated over and over. **Seed Mode** has the following options:
• **Non Repeating**: This is the default option. The seed is chosen based on the camera frame count. When the accumulation resets, it is not reset to zero.
• **Repeating**: The seed is reset every time the accumulation is reset. Rendering of every image is done using the same random numbers.
• **Custom**: Set the seed using a custom script. For more information, see the example in [Understand path tracing](path-tracing-understand.md).| -| **Denoising** | Denoises the output of the the path tracer. This setting is only available when you install the **Unity Denoising** Package. **Denoising** has the following options:
• **None**: Does not denoise (this is the default option).
• **Intel Open Image Denoise** : Uses the Intel Open Image Denoise library to denoise the frame.
• **NVIDIA OptiX** : Uses NVIDIA OptiX to denoise the frame.

You can also enable the following additional settings:
• **Use AOVs** (Arbitrary Output Variables): Increases the amount of detail kept in the frame after HDRP denoises it.
• **Temporal**: Improves the temporal consistency of denoised frame sequences.
• **Separate Volumetrics**: Denoises the volumetric scattering effect separately for a smoother fog. When Separate Volumetrics is enabled, the Temporal setting will not improve volumetric fog temporal stability. | +| **Denoising** | Denoises the output of the path tracer. This setting is only available when you install the **Unity Denoising** Package. **Denoising** has the following options:
• **None**: Does not denoise (this is the default option).
• **Intel Open Image Denoise** : Uses the Intel Open Image Denoise library to denoise the frame.
• **NVIDIA OptiX** : Uses NVIDIA OptiX to denoise the frame.

You can also enable the following additional settings:
• **Use AOVs** (Arbitrary Output Variables): Increases the amount of detail kept in the frame after HDRP denoises it.
• **Temporal**: Improves the temporal consistency of denoised frame sequences.
• **Separate Volumetrics**: Denoises the volumetric scattering effect separately for a smoother fog. When Separate Volumetrics is enabled, the Temporal setting will not improve volumetric fog temporal stability. | ![](Images/RayTracingPathTracing4.png) diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/reference-screen-space-reflection.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/reference-screen-space-reflection.md index febbc9ce467..51359e00b8d 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/reference-screen-space-reflection.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/reference-screen-space-reflection.md @@ -2,6 +2,11 @@ [!include[](snippets/Volume-Override-Enable-Properties.md)] +For more information, refer to the following: + +- [Use the screen space reflection (SSR) override](override-screen-space-reflection.md) +- [Understand reflection in HDRP](reflection-understand.md) + ### Screen-space | **Property** | **Description** | diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/rendering-and-post-processing.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/rendering-and-post-processing.md index 6514c19389b..e5bd1fced6f 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/rendering-and-post-processing.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/rendering-and-post-processing.md @@ -16,6 +16,6 @@ Control how the High Definition Render Pipeline (HDRP) renders a scene and apply |[Motion effects](motion-effects.md)|Apply effects to simulate the appearance of objects moving at speed.| |[Runtime effects](runtime-effects.md)|Use HDRP's API to control properties in a script at runtime.| |[Custom rendering effects](Custom-rendering.md)|Create an effect in a script and control when and how HDRP renders it.| -|[Customize the the High Definition Render Pipeline (HDRP)](render-graph.md)|Uses the [render graph system](https://docs.unity3d.com/Packages/com.unity.render-pipelines.core@latest/index.html?subfolder=/manual/render-graph-system.html) to add render pipeline features to HDRP.| +|[Customize the High Definition Render Pipeline (HDRP)](render-graph.md)|Uses the [render graph system](https://docs.unity3d.com/Packages/com.unity.render-pipelines.core@latest/index.html?subfolder=/manual/render-graph-system.html) to add render pipeline features to HDRP.| |[Troubleshoot rendering and post-processing issues]()|Fix common issues with custom effects.| diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/water-underwater-view.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/water-underwater-view.md index 38bed4d8441..60526ccc48a 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/water-underwater-view.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/water-underwater-view.md @@ -2,9 +2,21 @@ Underwater is rendered as a fullscreen postprocess effect. It uses either a simple analytic formula to estimate light absorption by the water volume, or if volumetric fog is enabled, it will be included in the vbuffer and rendered using volumetric lighting, supporting god rays and light shafts from shadows. -To view non-infinite water surfaces from underwater, you have to specify a [collider](https://docs.unity3d.com/Manual/Glossary.html#Collider). You can either use the box collider HDRP automatically provides or select a box collider in the scene to use for this purpose. +## Define the underwater area -To view infinite water surfaces from underwater, you have to specify a **Volume Depth**. +To change the area where the camera displays an underwater view for a non-infinite water surface, use the **Volume Bounds** setting. Follow these steps: + +1. Create a GameObject with a collider component, for example a cube with a **Box Collider** component. +2. Place the GameObject where you want the underwater view to be visible. +3. In the collider component, select **Edit Collider** to set the size of the visible underwater area. +4. Select the water GameObject. +5. In the **Inspector** window, under **Appearance**, under **Underwater**, set **Volume Bounds** to the GameObject you created. + +To set the area of the underwater view for an ocean, follow these steps: + +1. Select the ocean GameObject. +2. In the **Inspector** window, under **Appearance**, enable **Underwater**. +3. Adjust **Volume Depth**. # Water line diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/water-vfx-interaction.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/water-vfx-interaction.md index ee672f92560..107842f517e 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/water-vfx-interaction.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/water-vfx-interaction.md @@ -1,6 +1,6 @@ # Interaction between the Water System and the VFX Graph -The Water System supports being evaluated from the VFX Graph, to access data such as the the water height at a given point, the surface normal, or the current value. +The water system supports being evaluated from the VFX Graph, to access data such as the water height at a given point, the surface normal, or the current value. ![](Images/SampleWaterVFX.png) diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs index 06809f179be..d2d3258948f 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs @@ -188,7 +188,7 @@ void RayTracedReflectionGUI(RayCastingMode tracingMode) { HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing, "RayTracing"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing); if (RenderPipelineManager.currentPipeline is not HDRenderPipeline { rayTracingSupported: true }) HDRenderPipelineUI.DisplayRayTracingSupportBox(); @@ -261,7 +261,7 @@ public override void OnInspectorGUI() PropertyField(m_Enable, k_EnabledOpaque); if (!notSupported) - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.SSR, "Screen Space Reflection"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.SSR); bool transparentSSRSupported = currentAsset.currentPlatformRenderPipelineSettings.supportSSR && currentAsset.currentPlatformRenderPipelineSettings.supportSSRTransparent @@ -269,7 +269,7 @@ public override void OnInspectorGUI() if (transparentSSRSupported) { PropertyField(m_EnableTransparent, k_EnabledTransparent); - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.TransparentSSR, "Transparent"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.TransparentSSR); } else { diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/ScreenSpaceRefractionEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/ScreenSpaceRefractionEditor.cs index 656826674c0..1764e5b5325 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/ScreenSpaceRefractionEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/ScreenSpaceRefractionEditor.cs @@ -17,7 +17,7 @@ public override void OnEnable() public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Refraction, "Refraction"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Refraction); PropertyField(m_ScreenFadeDistance, k_ScreenFadeDistance); } diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/ScreenSpaceAmbientOcclusionEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/ScreenSpaceAmbientOcclusionEditor.cs index f79114ddb50..529f881118c 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/ScreenSpaceAmbientOcclusionEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/ScreenSpaceAmbientOcclusionEditor.cs @@ -101,7 +101,7 @@ private static class Styles public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.SSAO, "Screen Space Ambient Occlusion"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.SSAO); HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; bool notSupported = currentAsset != null && !currentAsset.currentPlatformRenderPipelineSettings.supportSSAO; if (notSupported) @@ -118,7 +118,7 @@ public override void OnInspectorGUI() if (m_RayTracing.overrideState.boolValue && m_RayTracing.value.boolValue) { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing, "RayTracing"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing); // If ray tracing is supported display the content of the volume component if (RenderPipelineManager.currentPipeline is not HDRenderPipeline { rayTracingSupported: true }) HDRenderPipelineUI.DisplayRayTracingSupportBox(); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/ContactShadowsEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/ContactShadowsEditor.cs index c18e5fd0442..aca2b43db85 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/ContactShadowsEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/ContactShadowsEditor.cs @@ -40,7 +40,7 @@ public override void OnEnable() public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.ContactShadows, "Contact Shadows"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.ContactShadows); PropertyField(m_Enable, EditorGUIUtility.TrTextContent("State", "When enabled, HDRP processes Contact Shadows for this Volume.")); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/HDShadowSettingsEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/HDShadowSettingsEditor.cs index 25f96f97601..68d02832c86 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/HDShadowSettingsEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/HDShadowSettingsEditor.cs @@ -45,7 +45,7 @@ public override void OnEnable() public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.ShadowMaps, "Shadow Maps"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.ShadowMaps); PropertyField(m_MaxShadowDistance, EditorGUIUtility.TrTextContent("Max Distance", "In Meter")); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/VolumetricClouds/VolumetricCloudsEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/VolumetricClouds/VolumetricCloudsEditor.cs index b7d9ba1dd16..9dd5d931daf 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/VolumetricClouds/VolumetricCloudsEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/VolumetricClouds/VolumetricCloudsEditor.cs @@ -523,7 +523,7 @@ public override void OnInspectorGUI() PropertyField(m_Enable, EditorGUIUtility.TrTextContent("State")); if (m_Enable.value.boolValue && !notSupported) - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.VolumetricClouds, "Volumetric Clouds"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.VolumetricClouds); EditorGUILayout.Space(); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/BloomEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/BloomEditor.cs index a6bff21b9c2..0c58027544e 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/BloomEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/BloomEditor.cs @@ -39,7 +39,7 @@ public override void OnEnable() public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Bloom, "Bloom"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Bloom); base.OnInspectorGUI(); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ChromaticAberrationEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ChromaticAberrationEditor.cs index eb057b82abf..f5ec875557c 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ChromaticAberrationEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ChromaticAberrationEditor.cs @@ -24,7 +24,7 @@ public override void OnEnable() public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.ChromaticAberration, "Chromatic Aberration"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.ChromaticAberration); PropertyField(m_SpectralLUT); PropertyField(m_Intensity); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/DepthOfFieldEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/DepthOfFieldEditor.cs index 1e8d19c6766..3165410858a 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/DepthOfFieldEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/DepthOfFieldEditor.cs @@ -86,7 +86,7 @@ public override void OnEnable() public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.DepthOfField, "Depth Of Field"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.DepthOfField); PropertyField(m_FocusMode, Styles.k_DepthOfFieldMode); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/FilmGrainEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/FilmGrainEditor.cs index d54b478d79a..edeec55e89d 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/FilmGrainEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/FilmGrainEditor.cs @@ -24,7 +24,7 @@ public override void OnEnable() public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.FilmGrain, "Film Grain"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.FilmGrain); PropertyField(m_Type); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/MotionBlurEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/MotionBlurEditor.cs index 648275afaf1..b7cc830db95 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/MotionBlurEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/MotionBlurEditor.cs @@ -41,7 +41,7 @@ public override void OnEnable() public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.MotionBlur, "Motion Blur"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.MotionBlur); PropertyField(m_Intensity); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/PaniniProjectionEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/PaniniProjectionEditor.cs index 85f32a97fc2..4424309d9c4 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/PaniniProjectionEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/PaniniProjectionEditor.cs @@ -22,7 +22,7 @@ public override void OnEnable() public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.PaniniProjection, "Panini Projection"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.PaniniProjection); PropertyField(m_Distance); PropertyField(m_CropToFit); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ScreenSpaceLensFlareEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ScreenSpaceLensFlareEditor.cs index 141cccf671d..e7b9023d6ed 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ScreenSpaceLensFlareEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ScreenSpaceLensFlareEditor.cs @@ -78,18 +78,9 @@ public override void OnEnable() public override void OnInspectorGUI() { - // We loop through each camera and displaying a message if there's any bloom intensity = 0 preventing lens flare to render. - foreach (HDCamera hdCamera in HDEditorUtils.GetAllCameras()) - { - var bloomComponent = hdCamera.volumeStack.GetComponent(); - if (bloomComponent != null && !bloomComponent.IsActive()) - { - EditorGUILayout.HelpBox("One or more Bloom override has an intensity set to 0. This prevents Screen Space Lens Flare to render.", MessageType.Warning); - break; - } - } - - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.LensFlareScreenSpace, "Screen Space Lens Flare"); + // We loop through each camera and displaying a message if there's any bloom intensity = 0 preventing lens flare to render. + HDEditorUtils.EnsureVolume((Bloom bloom) => !bloom.IsActive() ? "One or more Bloom override has an intensity set to 0. This prevents Screen Space Lens Flare to render." : null); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.LensFlareScreenSpace); if (!HDRenderPipeline.currentAsset?.currentPlatformRenderPipelineSettings.supportScreenSpaceLensFlare ?? false) { diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/TonemappingEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/TonemappingEditor.cs index 6ce8e473334..8ca9b7c030a 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/TonemappingEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/TonemappingEditor.cs @@ -85,7 +85,7 @@ internal bool HDROutputIsActive() public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Tonemapping, "Tonemapping"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Tonemapping); bool hdrInPlayerSettings = UnityEditor.PlayerSettings.allowHDRDisplaySupport; diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/VignetteEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/VignetteEditor.cs index eac7d7e3805..970dd53fd5d 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/VignetteEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/VignetteEditor.cs @@ -39,7 +39,7 @@ public override void OnEnable() public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Vignette, "Vignette"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Vignette); PropertyField(m_Mode); PropertyField(m_Color); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDEditorUtils.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDEditorUtils.cs index 9d2f7122f9e..d0162da14c9 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDEditorUtils.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDEditorUtils.cs @@ -321,7 +321,7 @@ static bool DataDrivenLensFlareHelpBox() return false; } - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.LensFlareDataDriven, "Lens Flare Data Driven"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.LensFlareDataDriven); return true; } @@ -336,76 +336,76 @@ static void OpenRenderingDebugger(string panelName) } } - static void HighlightInDebugger(HDCamera hdCamera, FrameSettingsField field, string displayName) + static void HighlightInDebugger(Camera camera, FrameSettingsField field, string displayName) { - OpenRenderingDebugger(hdCamera.camera.name); + OpenRenderingDebugger(camera.name); // Doesn't work for some reason //CoreEditorUtils.Highlight("Rendering Debugger", displayName, HighlightSearchMode.Auto); //GUIUtility.ExitGUI(); } - internal static void FrameSettingsHelpBox(HDCamera hdCamera, FrameSettingsField field, string displayName) + static IEnumerable GetAllCameras() { - var data = HDUtils.TryGetAdditionalCameraDataOrDefault(hdCamera.camera); - var defaults = GraphicsSettings.GetRenderPipelineSettings().GetDefaultFrameSettings(FrameSettingsRenderType.Camera); - - var type = MessageType.Warning; - var attribute = FrameSettingsExtractedDatas.GetFieldAttribute(field); - - bool disabledInGlobal = !defaults.IsEnabled(field); - bool disabledByCamera = data.renderingPathCustomFrameSettingsOverrideMask.mask[(uint)field] && - !data.renderingPathCustomFrameSettings.IsEnabled(field); - bool disabledByDependency = !attribute.dependencies.All(hdCamera.frameSettings.IsEnabled); - - var historyContainer = hdCamera.camera.cameraType == CameraType.SceneView - ? FrameSettingsHistory.sceneViewFrameSettingsContainer - : HDUtils.TryGetAdditionalCameraDataOrDefault(hdCamera.camera); - bool disabledByDebug = FrameSettingsHistory.enabled && !historyContainer.frameSettingsHistory.debug.IsEnabled(field) && historyContainer.frameSettingsHistory.sanitazed.IsEnabled(field); - - var textBase = $"The FrameSetting required to render this effect in the {(hdCamera.camera.cameraType == CameraType.SceneView ? "Scene" : "Game")} view "; - - if (disabledByDebug) - CoreEditorUtils.DrawFixMeBox(textBase + "is disabled in the Rendering Debugger.", type, "Open", () => HighlightInDebugger(hdCamera, field, displayName)); - else if (disabledByCamera) - CoreEditorUtils.DrawFixMeBox(textBase + "is disabled on a Camera.", type, "Open", () => EditorUtility.OpenPropertyEditor(hdCamera.camera)); - else if (disabledInGlobal) - GlobalSettingsHelpBox(textBase + "is disabled in the HDRP Global Settings.", type, field, displayName); - else if (disabledByDependency) - GlobalSettingsHelpBox(textBase + "depends on a disabled FrameSetting.", type, field, displayName); + foreach (SceneView sceneView in SceneView.sceneViews) + yield return sceneView.camera; + foreach (Camera camera in Camera.allCameras) + if (camera.cameraType == CameraType.Game) + yield return camera; } - - internal static HDCamera[] GetAllCameras() + + static IEnumerable<(Camera camera, FrameSettings @default, IFrameSettingsHistoryContainer historyContainer)> SelectFrameSettingsStages(IEnumerable cameras) { - HashSet cameras = new(); + var supportedFeatures = HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings; + var defaultSettings = GraphicsSettings.GetRenderPipelineSettings().GetDefaultFrameSettings(FrameSettingsRenderType.Camera); - // Looping through all the scene views - foreach (SceneView sceneView in SceneView.sceneViews) + foreach (var camera in cameras) { - if (!sceneView.hasFocus) continue; - cameras.Add(HDCamera.GetOrCreate(sceneView.camera)); + var additionalCameraData = HDUtils.TryGetAdditionalCameraDataOrDefault(camera); + var historyContainer = camera.cameraType == CameraType.SceneView ? FrameSettingsHistory.sceneViewFrameSettingsContainer : additionalCameraData; + + FrameSettings dummy = default; + FrameSettingsHistory.AggregateFrameSettings(ref dummy, camera, historyContainer, ref defaultSettings, supportedFeatures); + yield return (camera, defaultSettings, historyContainer); } + } + + static void FrameSettingsHelpBox(Camera camera, FrameSettingsField field, FrameSettings @default, IFrameSettingsHistoryContainer historyContainer) + { + FrameSettingsHistory history = historyContainer.frameSettingsHistory; + bool finalValue = history.debug.IsEnabled(field); + if (finalValue) return; //must be false to call this method - // Looping through all the game views - foreach (var camera in HDCamera.GetHDCameras()) - { - if (camera == null || camera.camera == null) - continue; + bool defaultValue = @default.IsEnabled(field); + bool cameraOverrideState = historyContainer.hasCustomFrameSettings && history.customMask.mask[(uint)field]; + bool cameraOverridenValue = history.overridden.IsEnabled(field); + bool cameraSanitizedValue = history.sanitazed.IsEnabled(field); - if (camera.camera.cameraType == CameraType.Game) - cameras.Add(camera); - } + var attribute = FrameSettingsExtractedDatas.GetFieldAttribute(field); + bool dependenciesSanitizedValueOk = attribute.dependencies.All(fs => attribute.IsNegativeDependency(fs) ? !history.sanitazed.IsEnabled(fs) : history.sanitazed.IsEnabled(fs)); + + bool disabledByDefault = !defaultValue && !cameraOverrideState; + bool disabledByCameraOverride = cameraOverrideState && !cameraOverridenValue; - return cameras.ToArray(); + var textBase = $"The FrameSetting required to render this effect in the {(camera.cameraType == CameraType.SceneView ? "Scene" : "Game")} view (by {camera.name}) "; + + if (disabledByDefault) + GlobalSettingsHelpBox(textBase + "is disabled in the HDRP Global Settings.", MessageType.Warning, field, attribute.displayedName); + else if (disabledByCameraOverride) + CoreEditorUtils.DrawFixMeBox(textBase + $"is disabled on the Camera.", MessageType.Warning, "Open", () => EditorUtility.OpenPropertyEditor(camera)); + else if (!dependenciesSanitizedValueOk) + GlobalSettingsHelpBox(textBase + "depends on a disabled FrameSetting.", MessageType.Warning, field, attribute.displayedName); + else if (!finalValue) + CoreEditorUtils.DrawFixMeBox(textBase + "is disabled in the Rendering Debugger.", MessageType.Warning, "Open", () => HighlightInDebugger(camera, field, attribute.displayedName)); } - internal static bool EnsureFrameSetting(FrameSettingsField field, string displayName) + internal static bool EnsureFrameSetting(FrameSettingsField field) { - foreach (var camera in GetAllCameras()) + foreach ((Camera camera, FrameSettings @default, IFrameSettingsHistoryContainer historyContainer) in SelectFrameSettingsStages(GetAllCameras())) { - if (!camera.frameSettings.IsEnabled(field)) + if (!historyContainer.frameSettingsHistory.debug.IsEnabled(field)) { - FrameSettingsHelpBox(camera, field, displayName); + FrameSettingsHelpBox(camera, field, @default, historyContainer); EditorGUILayout.Space(); return false; } @@ -413,31 +413,34 @@ internal static bool EnsureFrameSetting(FrameSettingsField field, string display return true; } - - internal static bool EnsureVolumeAndFrameSetting(Func volumeValidator, FrameSettingsField field, string displayName) where T : UnityEngine.Rendering.VolumeComponent + + static IEnumerable<(Camera camera, T component)> SelectVolumeComponent(IEnumerable cameras) where T : VolumeComponent { // Wait for volume system to be initialized if (VolumeManager.instance.baseComponentTypeArray == null) - return true; - - var cameras = GetAllCameras(); + yield break; - foreach (var camera in cameras) + foreach (var camera in GetAllCameras()) { - var errorString = volumeValidator(camera.volumeStack.GetComponent()); - if (!string.IsNullOrEmpty(errorString)) - { - EditorGUILayout.HelpBox(errorString, MessageType.Warning); - EditorGUILayout.Space(); - return false; - } + if (!HDCamera.TryGet(camera, out var hdCamera)) + continue; + + T component = hdCamera.volumeStack.GetComponent(); + if (component == null) + continue; + + yield return (camera, component); } + } - foreach (var camera in cameras) + internal static bool EnsureVolume(Func volumeValidator) where T : VolumeComponent + { + foreach ((Camera camera, T component) in SelectVolumeComponent(GetAllCameras())) { - if (!camera.frameSettings.IsEnabled(field)) + var errorString = volumeValidator(component); + if (!string.IsNullOrEmpty(errorString)) { - FrameSettingsHelpBox(camera, field, displayName); + EditorGUILayout.HelpBox(errorString, MessageType.Warning); EditorGUILayout.Space(); return false; } diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/LineRendering/HDRenderPipeline.LineRendering.VolumeComponentEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/LineRendering/HDRenderPipeline.LineRendering.VolumeComponentEditor.cs index 9557052ba7f..f7589519388 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/LineRendering/HDRenderPipeline.LineRendering.VolumeComponentEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/LineRendering/HDRenderPipeline.LineRendering.VolumeComponentEditor.cs @@ -30,7 +30,7 @@ public override void OnEnable() public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.HighQualityLineRendering, "High Quality Line Rendering"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.HighQualityLineRendering); HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; bool notSupported = currentAsset != null && !currentAsset.currentPlatformRenderPipelineSettings.supportHighQualityLineRendering; diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/PathTracing/PathTracingEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/PathTracing/PathTracingEditor.cs index d6f8e2494df..6dfee7b980c 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/PathTracing/PathTracingEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/PathTracing/PathTracingEditor.cs @@ -58,7 +58,7 @@ public override void OnEnable() public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing, "Path tracing"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing); HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; bool notSupported = currentAsset != null && !currentAsset.currentPlatformRenderPipelineSettings.supportRayTracing; diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs index 2a519601b93..12a4573e6c6 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs @@ -167,7 +167,7 @@ void RayTracingQualityModeGUI() public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.SSGI, "Screen Space Global Illumination"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.SSGI); HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; bool notSupported = !currentAsset?.currentPlatformRenderPipelineSettings.supportSSGI ?? false; @@ -197,7 +197,7 @@ public override void OnInspectorGUI() { if (rayTracingSettingsDisplayed) { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing, "RayTracing"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing); if (RenderPipelineManager.currentPipeline is not HDRenderPipeline { rayTracingSupported: true }) HDRenderPipelineUI.DisplayRayTracingSupportBox(); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/LightClusterEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/LightClusterEditor.cs index 68c5333cf2d..db48e44a337 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/LightClusterEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/LightClusterEditor.cs @@ -10,7 +10,7 @@ class LightClusterEditor : VolumeComponentEditor { public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing, "Raytracing"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing); HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; bool notSupported = currentAsset != null && !currentAsset.currentPlatformRenderPipelineSettings.supportRayTracing; diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RayTracingSettingsEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RayTracingSettingsEditor.cs index 8538075a55c..1ad4ed61aeb 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RayTracingSettingsEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RayTracingSettingsEditor.cs @@ -40,7 +40,7 @@ public override void OnEnable() public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing, "Raytracing"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing); HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; bool notSupported = currentAsset != null && !currentAsset.currentPlatformRenderPipelineSettings.supportRayTracing; diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RecursiveRenderingEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RecursiveRenderingEditor.cs index 476e16a576d..a1235987836 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RecursiveRenderingEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RecursiveRenderingEditor.cs @@ -37,7 +37,7 @@ public override void OnEnable() public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing, "Raytracing"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing); HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; bool notSupported = currentAsset != null && !currentAsset.currentPlatformRenderPipelineSettings.supportRayTracing; diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/SubSurfaceScatteringEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/SubSurfaceScatteringEditor.cs index ce2b3974e8f..88e690d4bbc 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/SubSurfaceScatteringEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/SubSurfaceScatteringEditor.cs @@ -20,7 +20,7 @@ public override void OnEnable() public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing, "Raytracing"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.RayTracing); HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; bool notSupported = currentAsset != null && !currentAsset.currentPlatformRenderPipelineSettings.supportRayTracing; diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Sky/AtmosphericScattering/FogEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Sky/AtmosphericScattering/FogEditor.cs index f0ac7f77513..8f4a2a826f0 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Sky/AtmosphericScattering/FogEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Sky/AtmosphericScattering/FogEditor.cs @@ -82,7 +82,7 @@ public override void OnEnable() public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.AtmosphericScattering, "Fog"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.AtmosphericScattering); PropertyField(m_Enabled, s_Enabled); @@ -124,7 +124,7 @@ public override void OnInspectorGUI() { PropertyField(m_EnableVolumetricFog, s_EnableVolumetricFog); - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Volumetrics, "Volumetric Fog"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Volumetrics); using (new IndentLevelScope()) { diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Water/WaterRenderingEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Water/WaterRenderingEditor.cs index 46b468e3702..6852e8092b8 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Water/WaterRenderingEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Water/WaterRenderingEditor.cs @@ -33,7 +33,7 @@ public override void OnEnable() public override void OnInspectorGUI() { - HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Water, "Water"); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Water); HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset; bool notSupported = currentAsset != null && !currentAsset.currentPlatformRenderPipelineSettings.supportWater; if (notSupported) diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Water/WaterSurface/WaterSurfaceEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Water/WaterSurface/WaterSurfaceEditor.cs index c1862aa4d30..d1425cbfb30 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Water/WaterSurface/WaterSurfaceEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Water/WaterSurface/WaterSurfaceEditor.cs @@ -292,8 +292,8 @@ public override void OnInspectorGUI() return; } - Func validator = (water) => !water.enable.value ? "Water Surface Rendering is not enabled in the Volume System." : null; - HDEditorUtils.EnsureVolumeAndFrameSetting(validator, FrameSettingsField.Water, "Water"); + HDEditorUtils.EnsureVolume((WaterRendering water) => !water.enable.value ? "Water Surface Rendering is not enabled in the Volume System." : null); + HDEditorUtils.EnsureFrameSetting(FrameSettingsField.Water); if (target is WaterSurface surface && surface.surfaceIndex == -1) { diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.Configuration.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.Configuration.cs index 494b89b572e..94db4490e1e 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.Configuration.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.Configuration.cs @@ -24,6 +24,13 @@ enum InclusiveMode enum QualityScope { Global, CurrentQuality } + enum Result + { + Failed, + OK, + Pending, + } + static class InclusiveScopeExtention { public static bool Contains(this InclusiveMode thisScope, InclusiveMode scope) @@ -109,14 +116,14 @@ struct Entry public readonly QualityScope scope; public readonly InclusiveMode inclusiveScope; public readonly Style.ConfigStyle configStyle; - public readonly Func check; + public readonly Func check; public readonly Action fix; public readonly int indent; public readonly bool forceDisplayCheck; public readonly bool skipErrorIcon; public readonly bool displayAssetName; - public Entry(QualityScope scope, InclusiveMode mode, Style.ConfigStyle configStyle, Func check, + public Entry(QualityScope scope, InclusiveMode mode, Style.ConfigStyle configStyle, Func check, Action fix, int indent = 0, bool forceDisplayCheck = false, bool skipErrorIcon = false, bool displayAssetName = false) { this.scope = scope; @@ -125,7 +132,21 @@ public Entry(QualityScope scope, InclusiveMode mode, Style.ConfigStyle configSty this.check = check; this.fix = fix; this.forceDisplayCheck = forceDisplayCheck; - this.indent = mode == InclusiveMode.XRManagement ? 1 : indent; + this.indent = indent; + this.skipErrorIcon = skipErrorIcon; + this.displayAssetName = displayAssetName; + } + + public Entry(QualityScope scope, InclusiveMode mode, Style.ConfigStyle configStyle, Func check, + Action fix, int indent = 0, bool forceDisplayCheck = false, bool skipErrorIcon = false, bool displayAssetName = false) + { + this.scope = scope; + this.inclusiveScope = mode; + this.configStyle = configStyle; + this.check = () => check() ? Result.OK : Result.Failed; + this.fix = fix; + this.forceDisplayCheck = forceDisplayCheck; + this.indent = indent; this.skipErrorIcon = skipErrorIcon; this.displayAssetName = displayAssetName; } @@ -177,8 +198,8 @@ Entry[] BuildEntryList() new Entry(QualityScope.Global, InclusiveMode.HDRP, Style.hdrpShadowmask, IsShadowmaskCorrect, FixShadowmask), new Entry(QualityScope.Global, InclusiveMode.HDRP, Style.hdrpMigratableAssets, IsMigratableAssetsCorrect, FixMigratableAssets), new Entry(QualityScope.Global, InclusiveMode.VR, Style.vrXRManagementPackage, IsVRXRManagementPackageInstalledCorrect, FixVRXRManagementPackageInstalled), - new Entry(QualityScope.Global, InclusiveMode.XRManagement, Style.vrOculusPlugin, () => false, null), - new Entry(QualityScope.Global, InclusiveMode.XRManagement, Style.vrSinglePassInstancing, () => false, null), + new Entry(QualityScope.Global, InclusiveMode.XRManagement, Style.vrOculusPlugin, () => false, null, indent: 1), + new Entry(QualityScope.Global, InclusiveMode.XRManagement, Style.vrSinglePassInstancing, () => false, null, indent: 1), new Entry(QualityScope.Global, InclusiveMode.VR, Style.vrLegacyHelpersPackage, IsVRLegacyHelpersCorrect, FixVRLegacyHelpers), new Entry(QualityScope.CurrentQuality, InclusiveMode.HDRP, Style.hdrpAssetQualityAssigned, IsHdrpAssetQualityUsedCorrect, FixHdrpAssetQualityUsed), new Entry(QualityScope.CurrentQuality, InclusiveMode.HDRP, Style.hdrpBatcher, IsSRPBatcherCorrect, FixSRPBatcher), @@ -255,7 +276,7 @@ bool IsAFixAvailableInScope(InclusiveMode scope) { if (!scope.Contains(e.inclusiveScope) || e.check == null || e.fix == null) continue; - if (!e.check()) + if (e.check() == Result.Failed) return false; } @@ -272,7 +293,7 @@ void FixAllEntryInScope(InclusiveMode scope) m_Fixer.Add(() => { - if (!e.check()) + if (e.check() == Result.Failed) e.fix(true); }); } @@ -621,13 +642,14 @@ void FixMigratableAssets(bool fromAsyncUnused) #region HDRP_VR_FIXES - bool vrXRManagementInstalledCheck = false; - bool IsVRXRManagementPackageInstalledCorrect() + Result m_vrXRManagementInstalledCheck = Result.Pending; + Result IsVRXRManagementPackageInstalledCorrect() => m_vrXRManagementInstalledCheck; + void UpdateVRXRManagementInstalledCheck() { + m_vrXRManagementInstalledCheck = Result.Pending; m_UsedPackageRetriever.ProcessAsync( k_XRanagementPackageName, - (installed, info) => vrXRManagementInstalledCheck = installed); - return vrXRManagementInstalledCheck; + (installed, info) => m_vrXRManagementInstalledCheck = installed ? Result.OK : Result.Failed); } void FixVRXRManagementPackageInstalled(bool fromAsync) @@ -637,13 +659,14 @@ void FixVRXRManagementPackageInstalled(bool fromAsync) m_PackageInstaller.ProcessAsync(k_XRanagementPackageName, null); } - bool vrLegacyHelpersInstalledCheck = false; - bool IsVRLegacyHelpersCorrect() + Result m_vrLegacyHelpersInstalledCheck = Result.Pending; + Result IsVRLegacyHelpersCorrect() => m_vrLegacyHelpersInstalledCheck; + void UpdateVRLegacyHelpersInstalledCheck() { + m_vrLegacyHelpersInstalledCheck = Result.Pending; m_UsedPackageRetriever.ProcessAsync( k_LegacyInputHelpersPackageName, - (installed, info) => vrLegacyHelpersInstalledCheck = installed); - return vrLegacyHelpersInstalledCheck; + (installed, info) => m_vrLegacyHelpersInstalledCheck = installed ? Result.OK : Result.Failed); } void FixVRLegacyHelpers(bool fromAsync) @@ -926,26 +949,25 @@ void EmbedConfigPackage(bool installed, string name, Action onCompletion) void InstallLocalConfigurationPackage(Action onCompletion) { m_UsedPackageRetriever.ProcessAsync( - k_HdrpConfigPackageName, - (installed, info) => - { - // Embedding a package requires it to be an explicit direct dependency in the manifest. - // If it's not, we add it first. - if (!info.isDirectDependency) + k_HdrpConfigPackageName, + (installed, info) => { - m_PackageInstaller.ProcessAsync(k_HdrpConfigPackageName, () => m_UsedPackageRetriever.ProcessAsync( - k_HdrpConfigPackageName, - (installed, info) => - { - EmbedConfigPackage(installed, info.name, onCompletion); - - })); - } - else - { - EmbedConfigPackage(installed, info.name, onCompletion); - } - }); + // Embedding a package requires it to be an explicit direct dependency in the manifest. + // If it's not, we add it first. + if (!info.isDirectDependency) + { + m_PackageInstaller.ProcessAsync(k_HdrpConfigPackageName, () => m_UsedPackageRetriever.ProcessAsync( + k_HdrpConfigPackageName, + (installed, info) => + { + EmbedConfigPackage(installed, info.name, onCompletion); + })); + } + else + { + EmbedConfigPackage(installed, info.name, onCompletion); + } + }); } @@ -963,6 +985,16 @@ void RefreshDisplayOfConfigPackageArea() IsLocalConfigurationPackageEmbeddedAsync(present => UpdateDisplayOfConfigPackageArea(present ? ConfigPackageState.Present : ConfigPackageState.Missing)); } + static void CheckPackages(PackageRegistrationEventArgs args) + { + if (EditorWindow.HasOpenInstances() && !EditorApplication.isPlayingOrWillChangePlaymode) + { + HDWizard window = EditorWindow.GetWindow(Style.title.text); + window.UpdateVRXRManagementInstalledCheck(); + window.UpdateVRLegacyHelpersInstalledCheck(); + } + } + class UsedPackageRetriever { PackageManager.Requests.ListRequest m_CurrentRequest; diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.UIElement.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.UIElement.cs index d6c6d116d21..a4cab89d5fa 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.UIElement.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.UIElement.cs @@ -169,11 +169,11 @@ void CreateOrLoad(Action onCancel, Action onObjectChanged) abstract class VisualElementUpdatable : VisualElement { - protected Func m_Tester; + protected Func m_Tester; bool m_HaveFixer; - public bool currentStatus { get; private set; } + public Result currentStatus { get; private set; } - protected VisualElementUpdatable(Func tester, bool haveFixer) + protected VisualElementUpdatable(Func tester, bool haveFixer) { m_Tester = tester; m_HaveFixer = haveFixer; @@ -181,7 +181,7 @@ protected VisualElementUpdatable(Func tester, bool haveFixer) public virtual void CheckUpdate() { - bool wellConfigured = m_Tester(); + var wellConfigured = m_Tester(); if (wellConfigured != currentStatus) currentStatus = wellConfigured; @@ -190,27 +190,7 @@ public virtual void CheckUpdate() public void Init() => UpdateDisplay(currentStatus, m_HaveFixer); - public abstract void UpdateDisplay(bool statusOK, bool haveFixer); - } - - class HiddableUpdatableContainer : VisualElementUpdatable - { - public HiddableUpdatableContainer(Func tester, bool haveFixer = false) : base(tester, haveFixer) { } - - public override void CheckUpdate() - { - base.CheckUpdate(); - if (currentStatus) - { - foreach (VisualElementUpdatable updatable in Children().Where(e => e is VisualElementUpdatable)) - updatable.CheckUpdate(); - } - } - - new public void Init() => base.Init(); - - public override void UpdateDisplay(bool visible, bool haveFixer) - => style.display = visible ? DisplayStyle.Flex : DisplayStyle.None; + public abstract void UpdateDisplay(Result status, bool haveFixer); } class ConfigInfoLine : VisualElementUpdatable @@ -224,6 +204,7 @@ static class Style readonly bool m_SkipErrorIcon; private Image m_StatusOk; private Image m_StatusKO; + private Image m_StatusPending; private Button m_Resolver; private HelpBox m_HelpBox; public ConfigInfoLine(Entry entry) @@ -232,7 +213,7 @@ public ConfigInfoLine(Entry entry) m_VisibleStatus = entry.configStyle.messageType == MessageType.Error || entry.forceDisplayCheck; m_SkipErrorIcon = entry.skipErrorIcon; - var testLabel = new UnityEngine.UIElements.Label(entry.configStyle.label) + var testLabel = new Label(entry.configStyle.label) { name = "TestLabel", style = @@ -271,8 +252,19 @@ public ConfigInfoLine(Entry entry) width = 16 } }; + m_StatusPending = new Image() + { + image = CoreEditorStyles.iconPending, + name = "StatusPending", + style = + { + height = 16, + width = 16 + } + }; testRow.Add(m_StatusOk); testRow.Add(m_StatusKO); + testRow.Add(m_StatusPending); Add(testRow); var kind = entry.configStyle.messageType switch @@ -293,7 +285,7 @@ public ConfigInfoLine(Entry entry) } m_HelpBox = new HelpBox(error, kind); - m_HelpBox.Q().style.flexGrow = 1; + m_HelpBox.Q