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 index bf340bb3b79..59bd163b680 100644 --- 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 @@ -55,16 +55,16 @@ public class MySettingsPropertyDrawer : PropertyDrawer 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. +1. Create a class that implements the [`IRenderPipelineGraphicsSettingsContextMenu2`](https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Rendering.IRenderPipelineGraphicsSettingsContextMenu2_1.html) interface. 2. Implement the `PopulateContextMenu` method. 3. To add an item, use the `AddItem` API. For example: ```c# -public class MySettingsContextMenu : IRenderPipelineGraphicsSettingsContextMenu +public class MySettingsContextMenu : IRenderPipelineGraphicsSettingsContextMenu2 { - void IRenderPipelineGraphicsSettingsContextMenu.PopulateContextMenu(MySettings setting, PropertyDrawer _, ref GenericMenu menu) + void IRenderPipelineGraphicsSettingsContextMenu2.PopulateContextMenu(MySettings setting, SerializedProperty _, ref GenericMenu menu) { menu.AddItem(new GUIContent("My custom menu item"), false, () => { Debug.Log("Menu item was selected."); }); } @@ -74,4 +74,5 @@ public class MySettingsContextMenu : IRenderPipelineGraphicsSettingsContextMenu< ## Additional resources - [PropertyDrawer](xref:UnityEditor.PropertyDrawer) -- [IRenderPipelineGraphicsSettingsContextMenu](https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Rendering.IRenderPipelineGraphicsSettingsContextMenu.html) +- [IRenderPipelineGraphicsSettingsContextMenu2](https://docs.unity3d.com/6000.2/Documentation/ScriptReference/Rendering.IRenderPipelineGraphicsSettingsContextMenu2.html) +- [IRenderPipelineGraphicsSettingsContextMenu2](https://docs.unity3d.com/6000.2/Documentation/ScriptReference/Rendering.IRenderPipelineGraphicsSettingsContextMenu2_1.html) diff --git a/Packages/com.unity.render-pipelines.core/Editor/Deprecated.cs b/Packages/com.unity.render-pipelines.core/Editor/Deprecated.cs index 700535aa3fb..faf5ac6672e 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Deprecated.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Deprecated.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.Rendering; +using UnityEngine.UIElements; namespace UnityEditor.Rendering { @@ -159,7 +160,28 @@ public DefaultVolumeProfileEditor(Editor baseEditor, VolumeProfile profile) } } + public abstract partial class DefaultVolumeProfileSettingsPropertyDrawer + { + /// + /// Context menu implementation for Default Volume Profile. + /// + /// Default Volume Profile Settings type + /// Render Pipeline type + [Obsolete("Use DefaultVolumeProfileSettingsPropertyDrawer.DefaultVolumeProfileSettingsContextMenu2 instead #from(6000.0)")] + public abstract class DefaultVolumeProfileSettingsContextMenu : IRenderPipelineGraphicsSettingsContextMenu + where TSetting : class, IDefaultVolumeProfileSettings + where TRenderPipeline : RenderPipeline + { + /// + /// Path where new Default Volume Profile will be created. + /// + [Obsolete("Not used anymore. #from(6000.0)")] + protected abstract string defaultVolumeProfilePath { get; } + [Obsolete("Not used anymore. #from(6000.0)")] + void IRenderPipelineGraphicsSettingsContextMenu.PopulateContextMenu(TSetting setting, PropertyDrawer property, ref GenericMenu menu){ } + } + } /// /// Builtin Drawer for Maskfield Debug Items. diff --git a/Packages/com.unity.render-pipelines.core/Editor/Settings/PropertyDrawers/DefaultVolumeProfileSettingsPropertyDrawer.cs b/Packages/com.unity.render-pipelines.core/Editor/Settings/PropertyDrawers/DefaultVolumeProfileSettingsPropertyDrawer.cs index b030fc73132..bd307155ce0 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Settings/PropertyDrawers/DefaultVolumeProfileSettingsPropertyDrawer.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Settings/PropertyDrawers/DefaultVolumeProfileSettingsPropertyDrawer.cs @@ -8,7 +8,7 @@ namespace UnityEditor.Rendering /// /// Base implementation for drawing Default Volume Profile UI in Graphics Settings. /// - public abstract class DefaultVolumeProfileSettingsPropertyDrawer : PropertyDrawer + public abstract partial class DefaultVolumeProfileSettingsPropertyDrawer : PropertyDrawer { // UUM-77758: Due to how PropertyDrawers are created and cached, there is no way to retrieve them reliably // later. We know that only one DefaultVolumeProfile exists at any given time, so we can access it through @@ -118,7 +118,7 @@ protected void DestroyDefaultVolumeProfileEditor() /// /// Default Volume Profile Settings type /// Render Pipeline type - public abstract class DefaultVolumeProfileSettingsContextMenu : IRenderPipelineGraphicsSettingsContextMenu + public abstract class DefaultVolumeProfileSettingsContextMenu2 : IRenderPipelineGraphicsSettingsContextMenu2 where TSetting : class, IDefaultVolumeProfileSettings where TRenderPipeline : RenderPipeline { @@ -127,7 +127,7 @@ public abstract class DefaultVolumeProfileSettingsContextMenu protected abstract string defaultVolumeProfilePath { get; } - void IRenderPipelineGraphicsSettingsContextMenu.PopulateContextMenu(TSetting setting, PropertyDrawer _, ref GenericMenu menu) + void IRenderPipelineGraphicsSettingsContextMenu2.PopulateContextMenu(TSetting setting, SerializedProperty _, ref GenericMenu menu) { bool canCreateNewAsset = RenderPipelineManager.currentPipeline is TRenderPipeline; VolumeProfileUtils.AddVolumeProfileContextMenuItems(ref menu, diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeManager.cs b/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeManager.cs index 0402bb496db..c1683467551 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeManager.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeManager.cs @@ -116,11 +116,23 @@ public sealed partial class VolumeManager .OrderBy(i => i.Item1) .ToList(); } + + Type[] m_BaseComponentTypeArray; /// /// The current list of all available types that derive from . /// - public Type[] baseComponentTypeArray { get; internal set; } // internal only for tests + public Type[] baseComponentTypeArray + { + get + { + if (isInitialized) + return m_BaseComponentTypeArray; + + throw new InvalidOperationException($"{nameof(VolumeManager)}.{nameof(instance)}.{nameof(baseComponentTypeArray)} cannot be called before the {nameof(VolumeManager)} is initialized. (See {nameof(VolumeManager)}.{nameof(instance)}.{nameof(isInitialized)} and {nameof(RenderPipelineManager)} for creation callback)."); + } + internal set => m_BaseComponentTypeArray = value; // internal only for tests + } /// /// Global default profile that provides default values for volume components. VolumeManager applies @@ -221,13 +233,19 @@ public void Initialize(VolumeProfile globalDefaultVolumeProfile = null, VolumePr Debug.Assert(m_CreatedVolumeStacks.Count == 0); LoadBaseTypes(GraphicsSettings.currentRenderPipelineAssetType); + InitializeInternal(globalDefaultVolumeProfile, qualityDefaultVolumeProfile); + } + + //This is called by test where the basetypes are tuned for the purpose of the test. + internal void InitializeInternal(VolumeProfile globalDefaultVolumeProfile = null, VolumeProfile qualityDefaultVolumeProfile = null) + { InitializeVolumeComponents(); globalDefaultProfile = globalDefaultVolumeProfile; qualityDefaultProfile = qualityDefaultVolumeProfile; EvaluateVolumeDefaultState(); - m_DefaultStack = CreateStack(); + m_DefaultStack = CreateStackInternal(); stack = m_DefaultStack; isInitialized = true; @@ -326,9 +344,17 @@ public void OnVolumeComponentChanged(VolumeComponent component) /// /// public VolumeStack CreateStack() + { + if (!isInitialized) + throw new InvalidOperationException($"{nameof(VolumeManager)}.{nameof(instance)}.{nameof(CreateStack)}() cannot be called before the {nameof(VolumeManager)} is initialized. (See {nameof(VolumeManager)}.{nameof(instance)}.{nameof(isInitialized)} and {nameof(RenderPipelineManager)} for creation callback)."); + + return CreateStackInternal(); + } + + VolumeStack CreateStackInternal() { var stack = new VolumeStack(); - stack.Reload(baseComponentTypeArray); + stack.Reload(m_BaseComponentTypeArray); m_CreatedVolumeStacks.Add(stack); return stack; } @@ -400,15 +426,18 @@ internal void LoadBaseTypes(Type pipelineAssetType) list.Add(t); } - baseComponentTypeArray = list.ToArray(); + m_BaseComponentTypeArray = list.ToArray(); } } internal void InitializeVolumeComponents() { + if (m_BaseComponentTypeArray == null || m_BaseComponentTypeArray.Length == 0) + return; + // Call custom static Init method if present var flags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; - foreach (var type in baseComponentTypeArray) + foreach (var type in m_BaseComponentTypeArray) { var initMethod = type.GetMethod("Init", flags); if (initMethod != null) @@ -419,9 +448,9 @@ internal void InitializeVolumeComponents() } // Evaluate static default values for VolumeComponents, which is the baseline to reset the values to at the start of Update. - internal void EvaluateVolumeDefaultState() + void EvaluateVolumeDefaultState() { - if (baseComponentTypeArray == null || baseComponentTypeArray.Length == 0) + if (m_BaseComponentTypeArray == null || m_BaseComponentTypeArray.Length == 0) return; using var profilerScope = k_ProfilerMarkerEvaluateVolumeDefaultState.Auto(); @@ -432,7 +461,7 @@ internal void EvaluateVolumeDefaultState() // First, default-construct all VolumeComponents List componentsDefaultStateList = new(); - foreach (var type in baseComponentTypeArray) + foreach (var type in m_BaseComponentTypeArray) { componentsDefaultStateList.Add((VolumeComponent) ScriptableObject.CreateInstance(type)); } diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/Override-Contact-Shadows.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/Override-Contact-Shadows.md index beeb0b453ca..8db8ebcbf42 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/Override-Contact-Shadows.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/Override-Contact-Shadows.md @@ -30,6 +30,8 @@ Enable the following properties: You can enable Contact Shadows on a per Light basis for Directional, Point, and Spot Lights. Tick the **Enable** checkbox under the **Contact Shadows** drop-down in the **Shadows** section of each Light to indicate that HDRP should calculate Contact Shadows for that Light. +If you use both contact shadows and [realtime shadows](realtime-shadows.md), there might be a visible seam between the two types of shadow. To avoid this issue, set shadow maps to use a high resolution. For more information, refer to [Control shadow resolution and quality](Shadows-in-HDRP.md). + **Note**: A Light casts Contact Shadows for every Mesh Renderer that uses a Material that writes to the depth buffer. This is regardless of whether you enable or disable the **Cast Shadows** property on the Mesh Renderer. This means that you can disable **Cast Shadows** on small GameObjects/props and still have them cast Contact Shadows. This is good if you do not want HDRP to render these GameObjects in shadow maps. If you do not want this behavior, use Shader Graph to author a Material that does not write to the depth buffer. [!include[](snippets/volume-override-api.md)] diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Shadows.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Shadows.md index ae7bc9b52a9..03eec488a97 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Shadows.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Shadows.md @@ -73,7 +73,7 @@ Ray-traced Directional Light shadows without colored shadows | **Sample Count** | Controls the number of rays that HDRP uses per pixel, per frame. Higher values produce more accurate shadows. Increasing this value increases execution time linearly. | | **Color Shadow** | Allows transparent and transmissive GameObjects to cast colored shadows. A Material can only cast colored shadows when its [**Refraction Model**](Surface-Type.md#transparency-inputs) is set to **Thin**, **Box** or **Sphere**. | | **Denoise** | Enables the spatio-temporal filter that HDRP uses to remove noise from the ray-traced shadows; making them smoother. | -| - **Denoiser Radius** | Controls the radius of the spatio-temporal filter. | +| - **Denoiser Radius** | Increases or decreases the blurriness between ray traced shadows, by controlling the radius of the spatio-temporal filter. | diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/reference-light-component.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/reference-light-component.md index eb941d397ac..1881ce43013 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/reference-light-component.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/reference-light-component.md @@ -9,34 +9,25 @@ The properties available for Lights are in separate sections. Each section conta - [Volumetrics](#Volumetric) - [Shadows](#Shadow) -### Animation +## Animation To make the Light work with the **Animation window**, when you click on the **Add Property** button, you need to use the properties inside the **HD Additional Light Data** component and not inside the Light component itself. If you do edit the properties inside the Light component, this modifies the built-in light values, which HDRP doesn't support. Alternatively, you can use the record button and modify the values directly inside the Inspector. -### General +## General **General** properties control the type of Light, how HDRP processes this Light, and whether this Light affects everything in the Scene or just GameObjects on a specific Rendering Layer. | **Property** | **Description** | | ------------------------ | ------------------------------------------------------------ | -| **Type** | Defines the Light’s type. Lights of different Types behave differently, so when you change the **Type**, the properties change in the Inspector. Possible types are:
• Directional
• Point
• Spot
• Area | +| **Type** | Defines the Light’s type. Lights of different Types behave differently, so when you change the **Type**, the properties change in the Inspector. For more information, refer to [Types of Light component](xref:um-lighting). Possible types are:
• Directional
• Point
• Spot
• Area | | **Mode** | Specify the [Light Mode](https://docs.unity3d.com/Manual/LightModes.html) that HDRP uses to determine how to bake a Light, if at all. Possible modes are:
• [Realtime](https://docs.unity3d.com/Manual/LightMode-Realtime.html): Unity performs the lighting calculations for Realtime Lights at runtime, once per frame.
• [Mixed](https://docs.unity3d.com/Manual/LightMode-Mixed.html): Mixed Lights combine elements of both realtime and baked lighting.
• [Baked](https://docs.unity3d.com/Manual/LightMode-Baked.html): Unity performs lighting calculations for Baked Lights in the Unity Editor, and saves the results to disk as lighting data. Note that soft falloff/range attenuation isn't supported for Baked Area Lights. | | **Rendering Layer Mask** | Defines which Rendering Layers this Light affects. The affected Light only lights up Mesh Renderers or Terrain with a matching **Rendering Layer Mask**. To use this property:
• Set up [light layers](Rendering-Layers.md) in your project.
• Enable [advanced properties](https://docs.unity3d.com/Packages/com.unity.render-pipelines.core@latest?subfolder=/manual/advanced-properties.html) for this section. | -#### Light Types guide - -| **Type** | **Description** | -| --------------- | ------------------------------------------------------------ | -| **Spot** | Emits light from a specified location and range over which the light diminishes. A Spot Light constrains the light it emits to an angle, which results in a cone-shaped region of illumination. The center of the cone points in the forward direction (z-axis) of the Light GameObject. Light also diminishes at the edges of the Spot Light’s cone. Increase the **Spot Angle** to increase the width of the cone. | -| **Directional** | Creates effects that are similar to sunlight in your Scene. Like sunlight, Directional Lights are distant light sources that HDRP treats as though they are infinitely far away. A Directional Light doesn't have any identifiable source position, and you can place the Light GameObject anywhere in the Scene.
A **Directional Light** illuminates all GameObjects in the Scene as if the Light rays are parallel and always from the same direction. The Light disregards the distance between the Light itself and the target GameObject, so the Light doesn't diminish with distance | -| **Point** | Projects light out equally in all directions from a point in space. The direction of light hitting a surface is the line from the point of contact back to the center of the Light GameObject. The light intensity diminishes with increased distance from the Light, and it reaches zero at the distance specified in the **Range** field.
Light intensity is inversely proportional to the square of the distance from the source. This is known as the [Inverse-square law](https://en.wikipedia.org/wiki/Inverse-square_law), and is similar to how light behaves in the real world. | -| **Area** | Projects light from a surface. Light shines in all directions uniformly from the surface of the rectangle. | - -### Shape +## Shape These settings define the area this Light affects. Each Light **Type** has its own unique **Shape** properties. @@ -54,7 +45,7 @@ These settings define the area this Light affects. Each Light **Type** has its o -#### Directional Light +### Directional Light | **Property** | **Description** | | -------------------- | ------------------------------------------------------------ | @@ -62,60 +53,67 @@ These settings define the area this Light affects. Each Light **Type** has its o -#### Point Light +### Point Light | **Property** | **Description** | | ------------ | ------------------------------------------------------------ | | **Radius** | Defines the radius of the light source. This has an impact on the size of specular highlights, diffuse lighting falloff and the smoothness of baked shadows and ray-traced shadows. | -#### Area Light +### Area Light -| **Property** | **Description** | -| ------------ | ------------------------------------------------------------ | -| **Shape** | HDRP Area Lights can use three shapes.
• **Rectangle** : Projects light from a rectangle shape at the GameObject’s position and orientation, in perpendicular direction, out to a certain **Range**.
• **Tube** : Projects light from a single line at the GameObject’s position in every direction, out to a certain **Range**. This shape is only for **Realtime Mode** at the moment.
• **Disc** : Projects light from a disc shape at the GameObject’s position and orientation, in perpendicular direction, out to a certain **Range**. This shape is only for **Baked Mode** at the moment. | -| **Size X** | For **Rectangle**. Defines the horizontal size of the Rectangle Light. | -| **Size Y** | For **Rectangle**. Defines the vertical size of the Rectangle Light. | -| **Length** | For **Tube**. Defines the length of the Tube Light. The center of the Light is the Transform Position and the Light itself extends out from the center symmetrically. The **Length** is the distance from one end of the tube to the other. | -| **Radius** | For **Disc**. Define the radius of the Disc Light. | +| **Property** | **Description** | +| -- | -- | +| **Shape** | HDRP Area Lights can use three shapes.
• **Rectangle** : Projects light from a rectangle shape at the GameObject’s position and orientation, perpendicularly, out to a certain **Range**.
• **Tube** : Projects light from a single line at the GameObject’s position in every direction, out to a certain **Range**. This shape is only for **Realtime Mode** at the moment.
• **Disc** : Projects light from a disc shape at the GameObject’s position and orientation, perpendicularly, out to a certain **Range**. This shape is only for **Baked Mode** at the moment. | +| **Size X** | For **Rectangle**. Defines the horizontal size of the Rectangle Light. | +| **Size Y** | For **Rectangle**. Defines the vertical size of the Rectangle Light. | +| **Length** | For **Tube**. Defines the length of the Tube Light. The center of the Light is the Transform Position and the Light itself extends out from the center symmetrically. The **Length** is the distance from one end of the tube to the other. | +| **Radius** | For **Disc**. Define the radius of the Disc Light. | -### Celestial Body (Directional only) +## Celestial Body (Directional only) These settings define the behavior of the light when you use it as a celestial body with the [Physically Based Sky](create-a-physically-based-sky.md). | **Property** | **Description** | | -------------------- | ------------------------------------------------------------ | | **Affect Physically Based Sky** | When using a **Physically Based Sky**, this displays a sun disc in the sky in this Light's direction. The diameter, color, and intensity of the sun disc match the properties of this Directional Light.
This property only appears when you enable [additional properties](More-Options.md) for this section. | -| **- Diameter Multiplier** | Controls the size of the sun disk by multiplying or overriding the value of the angular diameter. This allows artificially increasing the size of the celestial body on screen without impacting the specular highlights or softness of shadows. Additionally, if the sun is only a few pixels large and very bright, you might experience flickering when using bloom. Using an angular diameter multiplier for rendering the disk will solve this. | -| **- Distance** | Controls the distance of the sun disc. This is useful if you have multiple sun discs in the sky and want to change their sort order. HDRP draws sun discs with smaller **Distance** values on top of those with larger **Distance** values. | -| **- Surface Color** | Sets a 2D (disk) Texture and color multiplier for the surface of the celestial body. Rotate the light component on the Z axis to rotate this texture. | -| **- Shading** | Specify the light source used for shading of the Celestial Body.
• **Emission** : Used to simulate a Sun. The celestial body will emit light based on the intensity parameter set in the Emission section.
• **Reflect Sun Light** : Used to simulate moons or planets. The celestial body will be illuminated by a directionaly light.
• **Manual** : Used to simulate moons or planets with complete control over the phase angle and rotation, as well as the reflected light intensity. | -| **-- Sun Light Override** | Specifiy the Directional Light that should illuminate this Celestial Body. If not specified, HDRP will use the directional light in the scene with the highest intensity. | -| **-- Earthshine** | Controls the intensity of the light reflected from the planet onto the Celestial Body. | -| **-- Sun Color** | Color of the artificial light source in **Manual** mode. | -| **-- Sun Intensity** | Intensity of the artificial light source in **Manual** mode. | -| **-- Phase** | Controls the area of the surface illuminated by the Sun in **Manual** mode. A phase value of 0.5 means the surface is fully illuminated. | -| **-- Phase Rotation** | Rotates the Light Source relatively to the Celestial Body in **Manual** mode. | -| **- Flare Size** | Controls the size of the flare around the celestial body (in degrees). This is not a physically realist behavior but can be used to simulate sun flare when not using bloom or aerosol anisotropy of the PBR Sky.| -| **- Flare Falloff** | Controls the falloff rate of flare intensity as the angle from the light increases. | -| **- Flare Tint** | Controls the tint of the flare of the celestial body. | -| **- Flare Multiplier** | Multiplier applied on the flare intensity. | +| **Angular Diameter** | Controls the size of the sun disk by multiplying or overriding the value of the angular diameter. A higher angular diameter artificially increases the size of the celestial body on screen without impacting the specular highlights or softness of shadows. If the sun is only a few pixels large and very bright, you can also increase the angular diameter to avoid flickering when using bloom. | +| **Distance** | Controls the distance of the sun disc. This is useful if you have multiple sun discs in the sky and want to change their sort order. HDRP draws sun discs with smaller **Distance** values on top of those with larger **Distance** values. | +| **Surface Color** | Sets a 2D (disk) Texture and color multiplier for the surface of the celestial body. Rotate the light component on the Z axis to rotate this texture. | +| **Shading** | Specify the light source used for the shading of the Celestial Body.
• **Emission** : Simulates a Sun. The celestial body emits light based on the intensity parameter set in the Emission section.
• **Reflect Sun Light** : Simulates moons or planets. The celestial body is illuminated by a directional light.
• **Manual** : Simulates moons or planets with complete control over the phase angle and rotation, as well as the reflected light intensity. | +| **Flare Size** | Controls the size of the flare around the celestial body (in degrees). This is not a physically realist behavior but can be used to simulate sun flare when not using bloom or aerosol anisotropy of the PBR Sky.| +| **Flare Falloff** | Controls the falloff rate of flare intensity as the angle from the light increases. | +| **Flare Tint** | Controls the tint of the flare of the celestial body. | +| **Flare Multiplier** | Multiplies the flare intensity. | + +### Shading settings + +The following settings appear depending on the value of the **Shading** property. + +| **Property** | **Description** | +|-|-| +| **Sun Light Override** | Specify the Directional Light that should illuminate this Celestial Body. If not specified, HDRP uses the directional light in the scene with the highest intensity. | +| **Earthshine** | Controls the intensity of the light reflected from the planet onto the Celestial Body. | +| **Sun Color** | Sets the color of the artificial light source in **Manual** mode. | +| **Sun Intensity** | Sets the intensity of the artificial light source in **Manual** mode. | +| **Phase** | Controls the area of the surface illuminated by the Sun in **Manual** mode. A phase value of 0.5 means the surface is fully illuminated. | +| **Phase Rotation** | Rotates the light source relatively to the celestial body in **Manual** mode. | -### Emission +## Emission These settings define the emissive behavior of your Light. You can set the Light’s color, strength, and maximum range. If you don't see these properties in the Light Inspector, make sure you enable [advanced properties](https://docs.unity3d.com/Packages/com.unity.render-pipelines.core@latest?subfolder=/manual/advanced-properties.html). Most Lights share **Emission** properties. Below are the list of properties that more than one Light **Type** share, followed by unique properties only available for a single Light **Type**. -#### Shared Properties +### Shared Properties | **Property** | **Description** | | --------------------------- | ------------------------------------------------------------ | -| **Color Temperature** | Enable the checkbox to set the color temperature mode for this Light. Color Temperature mode adjusts the color of your Light based on a red-to-blue kelvin temperature scale. When enabled, this hides the **Color** property and exposes **Filter** and **Temperature**. Disable this checkbox to only display the **Color** field in the Inspector and use that as the Light color, without the temperature. | -| **- Filter** | Allows you to select the color of the Light’s filter using the color picker. HDRP uses this and the **Temperature** property to calculate the final color of the Light. | -| **- Temperature** | Allows you to select a temperature that HDRP uses to calculate a color on a red-to-blue kelvin temperature scale. You can move the slider along the scale itself, or specify an exact temperature value in the field below the slider scale.
This property includes an icon to the right of the slider which represents the light source that best matches the current value set. The icon is also a button which you can click to access a list of preset values that match real world light sources. | +| **Light Appearance** | Selects how to set the color of the Light. The options are:
  • Color: Displays the Color property so you can set the color of the Light.
  • Filter and Temperature : Displays the Filter and Temperature properties. Set the color of the Light based on a red-to-blue kelvin temperature scale.
| | **Color** | Allows you to select the color of the Light using the color picker. | +| **Filter** | Allows you to select the color of the Light’s filter using the color picker. HDRP uses this and the **Temperature** property to calculate the final color of the Light. | +| **Temperature** | Select a temperature on a red-to-blue kelvin scale that HDRP uses to calculate a color. Move the slider along the scale, or specify an exact temperature value in the field below the scale.
The icon to the right of the slider represents the light source that best matches the current value set. Click the icon to access a list of preset values that match real-world light sources. | | **Intensity** | The strength of the Light. Intensity is expressed in the following units:
• A Spot Light can use [Lumen](Physical-Light-Units.md#Lumen), [Candela](Physical-Light-Units.md#Candela), [Lux](Physical-Light-Units.md#Lux), and [EV100](Physical-Light-Units.md#EV).
• A Directional Light can only use **Lux**.
• A Point Light can use **Lumen**, **Candela**, **Lux**, and **EV100**.
• A Area Light can use **Lumen**, [Nits](Physical-Light-Units.md#Nits), and **EV100**.

Generally, the further the light travels from its source, the weaker it gets. The only exception to this is the **Directional Light** which has the same intensity regardless of distance. For the rest of the Light types, lower values cause light to diminish closer to the source. Higher values cause light to diminish further away from the source.

This property includes an icon to the right of the slider which represents the light source that best matches the current value set. The icon is also a button which you can click to access a list of preset values that match real world light sources. | | **Range** | The range of influence for this Light. Defines how far the emitted light reaches. This property is available for all **Light Types** except **Directional**. | | **Indirect Multiplier** | The intensity of [indirect](https://docs.unity3d.com/Manual/LightModes-TechnicalInformation.html) light in your Scene. A value of 1 mimics realistic light behavior. A value of 0 disables indirect lighting for this Light. If both **Realtime** and **Baked** Global Illumination are disabled in Lighting Settings (menu: **Window > Rendering > Lighting Settings**), the Indirect Multiplier has no effect. | @@ -131,13 +129,13 @@ These settings define the emissive behavior of your Light. You can set the Light | **Include For Ray Tracing** | Enable the checkbox to make this Light active when you enable the **Ray Tracing** [Frame Setting](Frame-Settings.md) on the Camera. This applies to rasterization and [ray tracing](Ray-Tracing-Getting-Started.md) passes.
This property only appears when you enable [advanced properties](https://docs.unity3d.com/Packages/com.unity.render-pipelines.core@latest?subfolder=/manual/advanced-properties.html) for this section. It's only available in Realtime or Mixed light **Mode**. | | **Include For Path Tracing** | Enable the checkbox to make this Light active when [Path Tracing](Ray-Tracing-Path-Tracing.md) is enabled. | -#### Spot Light +### Spot Light | **Property** | **Description** | | ------------- | ------------------------------------------------------------ | | **Reflector** | Enable the checkbox to simulate a reflective surface behind the Spot Light. Spot Lights are Point Lights that are partly occluded at the back by a reflective surface. Simulating this reflective surface increases the intensity of the Spot Light because the reflective surface reflects light originally directed backwards to focus the intensity in the Spot Light’s direction. | -#### Directional Light +### Directional Light | **Property** | **Description** | | ------------ | ------------------------------------------------------------ | @@ -146,33 +144,28 @@ These settings define the emissive behavior of your Light. You can set the Light -### Volumetrics +## Volumetrics These settings define the volumetric behavior of this Light. Alter these settings to change how this Light behaves with [Atmospheric Scattering](Atmospheric-Scattering.md). All Light **Types** share the same **Volumetric** properties, except **Area** Light. It's only available in Realtime or Mixed light **Mode**. -#### Shared Properties - | **Property** | **Description** | | ----------------- | ------------------------------------------------------------ | -| **Enable** | Enable the checkbox to simulate light scattering through volumetric fog. Enabling this property allows you to edit the **Dimmer** and **Shadow Dimmer** properties. | -| **Dimmer** | Dims the volumetric lighting effect of this Light. | +| **Enable** | Enable the checkbox to simulate light scattering through volumetric fog. Enabling this property allows you to edit the **Multiplier** and **Shadow Dimmer** properties. | +| **Multiplier** | Sets the intensity of the volumetric lighting effect of this Light. | | **Shadow Dimmer** | Dims the volumetric fog effect of this Light. Set this property to 0 to make the volumetric scattering compute faster. | -### **Shadows** +## **Shadows** Use this section to adjust the Shadows cast by this Light. Unity exposes extra properties in this section depending on the **Mode** you set in the [General](#general) section. Unity also exposes extra properties depending on the **Filtering Quality** set in your Unity Project’s [HDRP Asset](HDRP-Asset.md). -• For more information on shadow filtering in HDRP, see [Shadow Filtering](Shadows-in-HDRP.md##ShadowFiltering). - -• For a list of the available filter quality presets in HDRP, see the [Filtering Qualities table](HDRP-Asset.md#filtering-quality). - -#### Properties +For more information on shadow filtering in HDRP, refer to [Shadow Filtering](Shadows-in-HDRP.md##ShadowFiltering). +For a list of the available filter quality presets in HDRP, refer to the [Filtering Qualities table](HDRP-Asset.md#filtering-quality). -##### Shadow Map +### Shadow Map This section is only available in Realtime or Mixed light **Mode**. @@ -199,7 +192,7 @@ This section is only available in Realtime or Mixed light **Mode**. | **Custom Shadow Layers** | Enable the checkbox to use a different [Rendering Layer Mask](Rendering-Layers.md) for shadows than the one used for lighting. If you enable this feature, then HDRP uses the **Shadow Layers** drop-down in this section for shadowing. If you disable it, then HDRP uses the **Rendering Layer Mask** drop-down in the **General** section for shadowing.
This property only appears when you enable [advanced properties](https://docs.unity3d.com/Packages/com.unity.render-pipelines.core@latest?subfolder=/manual/advanced-properties.html) for this section. To access this property, enable **Light Layers** in your [HDRP Asset](HDRP-Asset.md). | | **Shadow Layers** | Use the drop-down to set the [Rendering Layer Mask](Rendering-Layers.md) HDRP uses for shadowing. This Light therefore only casts shadows for GameObjects that use a matching Rendering Layer. For more information about using Rendering Layers for shadowing, see [Shadow Light Layers](Rendering-Layers.md#ShadowLightLayers).
This property only appears when you enable [advanced properties](https://docs.unity3d.com/Packages/com.unity.render-pipelines.core@latest?subfolder=/manual/advanced-properties.html) for this section. To access this property, enable the **Custom Shadow Layers** checkbox. | -##### Contact Shadows +### Contact Shadows This section is only available in Realtime or Mixed light **Mode**. @@ -207,7 +200,7 @@ This section is only available in Realtime or Mixed light **Mode**. | ------------ | ------------------------------------------------------------ | | **Enable** | Add [Contact Shadows](Override-Contact-Shadows.md) to this Light. Use the drop-down to select a quality mode for the Contact Shadows. Select **Custom** to expose a checkbox that allows you to enable or disable Contact Shadows at will. | -##### Baked Shadows +### Baked Shadows This section is only available in Baked light **Mode**. @@ -216,13 +209,18 @@ This section is only available in Baked light **Mode**. | **Enable** | Enable the checkbox to let this Light cast shadows. | | **Near Plane** | The distance, in meters, from the Light that GameObjects begin to cast shadows. | -##### High Filtering Quality properties +### High Quality Settings In your [HDRP Asset](HDRP-Asset.md), select **High** from the **Filtering Quality** drop-down to expose the following properties. -| **Property** | **Description** | -| ------------------------------ | ------------------------------------------------------------ | -| **Shadow Softness** | Defines the behavior of area light shadows. Higher softness values mimic a larger emission radius while lower values mimic a [punctual light](Glossary.md#PunctualLight). High values increase shadow blur depending on the distance between the pixel receiving the shadow and the shadow caster. | -| **Blocker Sample Count** | The number of samples HDRP uses to evaluate the distance between the pixel receiving the shadow and the shadow caster. Higher values give better accuracy. | -| **Filter Sample Count** | The number of samples HDRP uses to blur shadows. Higher values give smoother results. | -| **Minimum Size of the Filter** | The minimum size of the whole shadow’s blur effect, no matter the distance between the pixel and the shadow caster. Higher values give blurrier results. | +| **Property** | **Description** | +|-|-| +| **Max Penumbra Size** | Sets the maximum blurriness of the edge of shadows that HDRP calculates as percentage-closer soft shadows (PCSS). If you increase this value, you might need to increase **Blocker Sample Count** and **Filter Sample Count** to maintain shadow quality. | +| **Max Sampling Distance** | Sets the distance from the shadow receiver where the edge of shadows reaches the **Max Penumbra Size**. Lower values reduce light bleeding, but might increase self-shadowing. | +| **Min Filter** | The minimum size of the whole shadow’s blur effect, no matter the distance between the pixel and the shadow caster. Higher values give blurrier results. | +| **Min Filter Max Angular Diameter** | Specifies how small shadows can get before HDRP uses the **Min Filter** size. Lower values help reduce self-shadowing. Higher values might increase light bleeding. | +| **Blocker Search Angular Diameter** | Specifies how much of the shadow map HDRP searches to find shadow casters, also known as blockers. Increasing this value might detect hidden or close shadow casters, but might also increase self-shadowing. | +| **Blocker Sampling Clump Exponent** | Adjusts the distribution of samples when HDRP searches for shadow casters in the shadow map. Higher values concentrate samples closer to the center, affecting the accuracy and blurriness of the shadow edge. | +| **Blocker Sample Count** | Sets the number of samples HDRP uses to calculate the distance between the pixel receiving the shadow and the shadow caster. Higher values give better accuracy. | +| **Filter Sample Count** | Sets the number of samples HDRP uses to blur shadows. Higher values give smoother results. | +| **Radius Scale for Softness** | Scales the radius that HDRP uses to calculate blurriness from the light source. Higher values give larger, blurrier results. | diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/rendering-debugger-window-reference.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/rendering-debugger-window-reference.md index 6703870b95c..2c3f2d1b6db 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/rendering-debugger-window-reference.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/rendering-debugger-window-reference.md @@ -220,7 +220,7 @@ These settings make it possible for you to visualize [Adaptive Probe Volumes](pr | **Property** | **Sub-property** | **Description** | |--------------------------|--------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | **Display Probes** | N/A | Display probes. | -| **Display Probes** | **Probe Shading Mode** | Set what the Rendering Debugger displays. The options are:
  • SH: Display the [spherical harmonics (SH) lighting data](https://docs.unity3d.com/Manual/LightProbes-TechnicalInformation.html) for the final color calculation. The number of bands depends on the **SH Bands** setting in the active [HDRP Asset](HDRP-Asset.md).
  • SHL0: Display the spherical harmonics (SH) lighting data with only the first band.
  • SHL0L1: Display the spherical Harmonics (SH) lighting data with the first two bands.
  • Validity: Display whether probes are valid, based on the number of backfaces the probe samples. Refer to [Fix issues with Adaptive Probe Volumes](probevolumes-fixissues.md) for more information about probe validity.
  • Probe Validity Over Dilation Threshold: Display red if a probe samples too many backfaces, based on the **Validity Threshold** set in the [Adaptive Probe Volumes panel](probevolumes-lighting-panel-reference.md). This means the probe can't be baked or sampled.
  • Invalidated By Touchup Volumes: Display probes that a [Probe Adjustment Volume component](probevolumes-adjustment-volume-component-reference.md) has made invalid.
  • Size: Display a different color for each size of [brick](probevolumes-concept.md).
  • Sky Occlusion SH: If you enable [sky occlusion](probevolumes-skyocclusion.md), this setting displays the amount of indirect light the probe receives from the sky that bounced off static GameObjects. The value is a scalar, so it displays as a shade of gray.
  • Sky Direction: Display a green circle that represents the direction from the probe to the sky. This setting displays a red circle if Unity can't calculate the direction, or **Sky Direction** in the [Adaptive Probe Volumes panel](probevolumes-lighting-panel-reference.md) is disabled.
| +| **Display Probes** | **Probe Shading Mode** | Set what the Rendering Debugger displays. The options are:
  • SH: Display the [spherical harmonics (SH) lighting data](https://docs.unity3d.com/Manual/LightProbes-TechnicalInformation.html) for the final color calculation. The number of bands depends on the **SH Bands** setting in the active [HDRP Asset](HDRP-Asset.md).
  • SHL0: Display the spherical harmonics (SH) lighting data with only the first band.
  • SHL0L1: Display the spherical Harmonics (SH) lighting data with the first two bands.
  • Validity: Display whether probes are valid, based on the number of backfaces the probe samples. Refer to [Fix issues with Adaptive Probe Volumes](probevolumes-fixissues.md) for more information about probe validity.
  • Probe Validity Over Dilation Threshold: Display red if a probe samples too many backfaces, based on the **Validity Threshold** set in the [Adaptive Probe Volumes panel](probevolumes-lighting-panel-reference.md). This means the probe can't be baked or sampled.
  • Invalidated By Adjustment Volumes: Display probes that a [Probe Adjustment Volume component](probevolumes-adjustment-volume-component-reference.md) has made invalid.
  • Size: Display a different color for each size of [brick](probevolumes-concept.md).
  • Sky Occlusion SH: If you enable [sky occlusion](probevolumes-skyocclusion.md), this setting displays the amount of indirect light the probe receives from the sky that bounced off static GameObjects. The value is a scalar, so it displays as a shade of gray.
  • Sky Direction: Display a green circle that represents the direction from the probe to the sky. This setting displays a red circle if Unity can't calculate the direction, or **Sky Direction** in the [Adaptive Probe Volumes panel](../probevolumes-lighting-panel-reference) is disabled.
  • **Probe Occlusion**: Displays whether probes are affected by lights that have their [Light Mode](https://docs.unity3d.com/Manual/LightModes-choose) set to **Mixed**, if you set [Lighting Mode](https://docs.unity3d.com/Manual/lighting-mode) to Shadowmask. Each probe displays up to four overlapping lights.
| | **Display Probes** | **Debug Size** | Set the size of the displayed probes. The default is 0.3. | | **Display Probes** | **Exposure Compensation** | Set the brightness of the displayed probes. Decrease the value to increase brightness. The default is 0. This property appears only if you set **Probe Shading Mode** to **SH**, **SHL0**, or **SHL0L1**. | | **Display Probes** | **Max Subdivisions Displayed** | Set the lowest probe density to display. For example, set this to 0 to display only the highest probe density. | diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs index 78c94c8aa18..62f10b2168a 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs @@ -630,9 +630,9 @@ void UpdateSizeOfOneTarget(DecalProjector currentTarget) m_SizeValues[axe].floatValue = newSize; } - internal void MinMaxSliderWithFields(GUIContent label, ref float minValue, ref float maxValue, float minLimit, float maxLimit) + internal void MinMaxSliderWithFields(Rect rect, GUIContent label, ref float minValue, ref float maxValue, float minLimit, float maxLimit) { - var rect = EditorGUILayout.GetControlRect(); + // Reserve label space and push the slider rect to the right rect = EditorGUI.PrefixLabel(rect, label); const float fieldWidth = 40, padding = 4; @@ -662,6 +662,45 @@ internal void MinMaxSliderWithFields(GUIContent label, ref float minValue, ref f } } + void DoRenderingLayerMask() + { + Rect rect = EditorGUILayout.GetControlRect(true, 18f); + EditorGUI.BeginProperty(rect, k_DecalLayerMaskContent, m_DecalLayerMask); + + var mask = m_DecalLayerMask.uintValue; + EditorGUI.BeginChangeCheck(); + mask = EditorGUI.RenderingLayerMaskField(rect, k_DecalLayerMaskContent, (RenderingLayerMask)mask, EditorStyles.layerMaskField); + if (EditorGUI.EndChangeCheck()) + { + m_DecalLayerMask.intValue = unchecked((int) mask); + serializedObject.ApplyModifiedProperties(); + } + + EditorGUI.EndProperty(); + } + + void DoAngleFade() + { + // The slider edits 2 different properties. Both can be overridden separately. + var rect = EditorGUILayout.GetControlRect(); + EditorGUI.BeginProperty(rect, k_AngleFadeContent, m_StartAngleFadeProperty); + EditorGUI.BeginProperty(rect, k_AngleFadeContent, m_EndAngleFadeProperty); + + float angleFadeMinValue = m_StartAngleFadeProperty.floatValue; + float angleFadeMaxValue = m_EndAngleFadeProperty.floatValue; + EditorGUI.BeginChangeCheck(); + MinMaxSliderWithFields(rect,k_AngleFadeContent, ref angleFadeMinValue, ref angleFadeMaxValue, 0.0f, 180.0f); + if (EditorGUI.EndChangeCheck()) + { + m_StartAngleFadeProperty.floatValue = angleFadeMinValue; + m_EndAngleFadeProperty.floatValue = angleFadeMaxValue; + serializedObject.ApplyModifiedProperties(); + } + + EditorGUI.EndProperty(); + EditorGUI.EndProperty(); + } + public override void OnInspectorGUI() { bool supportDecals = false; @@ -735,14 +774,7 @@ public override void OnInspectorGUI() decalLayerEnabled = supportDecals && hdrp.currentPlatformRenderPipelineSettings.supportDecalLayers; using (new EditorGUI.DisabledScope(!decalLayerEnabled)) { - var mask = m_DecalLayerMask.uintValue; - EditorGUI.BeginChangeCheck(); - mask = EditorGUILayout.RenderingLayerMaskField(k_DecalLayerMaskContent, mask); - if (EditorGUI.EndChangeCheck()) - { - m_DecalLayerMask.intValue = unchecked((int) mask); - EditorUtility.SetDirty(m_DecalLayerMask.serializedObject.targetObject); - } + DoRenderingLayerMask(); } } @@ -758,15 +790,7 @@ public override void OnInspectorGUI() EditorGUILayout.PropertyField(m_FadeScaleProperty, k_FadeScaleContent); using (new EditorGUI.DisabledScope(!decalLayerEnabled)) { - float angleFadeMinValue = m_StartAngleFadeProperty.floatValue; - float angleFadeMaxValue = m_EndAngleFadeProperty.floatValue; - EditorGUI.BeginChangeCheck(); - MinMaxSliderWithFields(k_AngleFadeContent, ref angleFadeMinValue, ref angleFadeMaxValue, 0.0f, 180.0f); - if (EditorGUI.EndChangeCheck()) - { - m_StartAngleFadeProperty.floatValue = angleFadeMinValue; - m_EndAngleFadeProperty.floatValue = angleFadeMaxValue; - } + DoAngleFade(); } if (!decalLayerEnabled) @@ -985,7 +1009,7 @@ public override void Action(int instanceId, string pathName, string resourceFile } if (shader != null) - { + { var material = new Material(shader); AssetDatabase.CreateAsset(material, materialName); ProjectWindowUtil.ShowCreatedAsset(material); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/PropertyDrawers/HDRPDefaultVolumeProfileSettingsPropertyDrawer.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/PropertyDrawers/HDRPDefaultVolumeProfileSettingsPropertyDrawer.cs index b9106bdb0f1..f5695a30189 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/PropertyDrawers/HDRPDefaultVolumeProfileSettingsPropertyDrawer.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/PropertyDrawers/HDRPDefaultVolumeProfileSettingsPropertyDrawer.cs @@ -92,7 +92,7 @@ protected override VisualElement CreateAssetFieldUI() return profileLine; } - public class HDRPDefaultVolumeProfileSettingsContextMenu : DefaultVolumeProfileSettingsContextMenu + public class HDRPDefaultVolumeProfileSettingsContextMenu : DefaultVolumeProfileSettingsContextMenu2 { protected override string defaultVolumeProfilePath { diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Settings/HDRPDefaultVolumeProfileSetting.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Settings/HDRPDefaultVolumeProfileSetting.cs index 981ae4c57d9..32e01f304cf 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Settings/HDRPDefaultVolumeProfileSetting.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Settings/HDRPDefaultVolumeProfileSetting.cs @@ -43,9 +43,9 @@ public VolumeProfile volumeProfile #if UNITY_EDITOR //Overriding "Reset" in menu that is not called at HDRPDefaultVolumeProfileSettings creation such Reset() - struct ResetImplementation : IRenderPipelineGraphicsSettingsContextMenu + struct ResetImplementation : IRenderPipelineGraphicsSettingsContextMenu2 { - public void PopulateContextMenu(HDRPDefaultVolumeProfileSettings setting, PropertyDrawer drawer, ref GenericMenu menu) + public void PopulateContextMenu(HDRPDefaultVolumeProfileSettings setting, SerializedProperty _, ref GenericMenu menu) { void Reset() { diff --git a/Packages/com.unity.render-pipelines.universal/Editor/AssetPostProcessors/MaterialPostprocessor.cs b/Packages/com.unity.render-pipelines.universal/Editor/AssetPostProcessors/MaterialPostprocessor.cs index 7f2e06d4e42..0ba9bca43f2 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/AssetPostProcessors/MaterialPostprocessor.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/AssetPostProcessors/MaterialPostprocessor.cs @@ -89,7 +89,7 @@ class MaterialPostprocessor : AssetPostprocessor internal static List s_ImportedAssetThatNeedSaving = new List(); internal static bool s_NeedsSavingAssets = false; - internal static readonly Action[] k_Upgraders = { UpgradeV1, UpgradeV2, UpgradeV3, UpgradeV4, UpgradeV5, UpgradeV6, UpgradeV7, UpgradeV8, UpgradeV9 }; + internal static readonly Action[] k_Upgraders = { UpgradeV1, UpgradeV2, UpgradeV3, UpgradeV4, UpgradeV5, UpgradeV6, UpgradeV7, UpgradeV8, UpgradeV9, UpgradeV10 }; static internal void SaveAssetsToDisk() { @@ -416,7 +416,7 @@ static void UpgradeV8(Material material, ShaderID shaderID) // We want to disable the custom motion vector pass for SpeedTrees which won't have any // vertex animation due to no wind. This is done to prevent performance regression from - // rendering trees with no motion vector output. + // rendering trees with no motion vector output. static void UpgradeV9(Material material, ShaderID shaderID) { if(shaderID != ShaderID.SpeedTree8) @@ -429,6 +429,19 @@ static void UpgradeV9(Material material, ShaderID shaderID) material.SetShaderPassEnabled(MotionVectorRenderPass.k_MotionVectorsLightModeTag, motionVectorPassEnabled); } } + + // Changed the emission-toggle evaluation. Need to make sure materials which enabled emission previously, still + // enable it after this fix. + static void UpgradeV10(Material material, ShaderID shaderID) + { + if ((material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.EmissiveIsBlack) == 0) + { + material.globalIlluminationFlags |= MaterialGlobalIlluminationFlags.BakedEmissive; + if (material.HasProperty(Property.EmissionColor)) + MaterialEditor.FixupEmissiveFlag(material); + CoreUtils.SetKeyword(material, ShaderKeywordStrings._EMISSION, (material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.AnyEmissive) != 0); + } + } } // Upgraders v1 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Materials/Black.mat b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Materials/Black.mat index 2d15203f0f2..b9b9f0afa7c 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Materials/Black.mat +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Materials/Black.mat @@ -133,4 +133,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} m_Name: m_EditorClassIdentifier: - version: 9 + version: 10 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Materials/Gold.mat b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Materials/Gold.mat index d3f8241a25b..c018ea6e9e7 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Materials/Gold.mat +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Materials/Gold.mat @@ -133,4 +133,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} m_Name: m_EditorClassIdentifier: - version: 9 + version: 10 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Materials/Ground.mat b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Materials/Ground.mat index 277b2bf086b..3fc07fb997b 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Materials/Ground.mat +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Materials/Ground.mat @@ -133,4 +133,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} m_Name: m_EditorClassIdentifier: - version: 9 + version: 10 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Materials/White.mat b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Materials/White.mat index fbeb823ecc2..fb2ecdea273 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Materials/White.mat +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Materials/White.mat @@ -133,4 +133,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} m_Name: m_EditorClassIdentifier: - version: 9 + version: 10 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/Settings/PropertyDrawers/URPDefaultVolumeProfileSettingsPropertyDrawer.cs b/Packages/com.unity.render-pipelines.universal/Editor/Settings/PropertyDrawers/URPDefaultVolumeProfileSettingsPropertyDrawer.cs index 461742b9dd3..11f03010f52 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/Settings/PropertyDrawers/URPDefaultVolumeProfileSettingsPropertyDrawer.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/Settings/PropertyDrawers/URPDefaultVolumeProfileSettingsPropertyDrawer.cs @@ -86,7 +86,7 @@ protected override VisualElement CreateAssetFieldUI() return profileLine; } - public class URPDefaultVolumeProfileSettingsContextMenu : DefaultVolumeProfileSettingsContextMenu + public class URPDefaultVolumeProfileSettingsContextMenu : DefaultVolumeProfileSettingsContextMenu2 { protected override string defaultVolumeProfilePath => "Assets/VolumeProfile_Default.asset"; } diff --git a/Packages/com.unity.render-pipelines.universal/Editor/ShaderGUI/BaseShaderGUI.cs b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGUI/BaseShaderGUI.cs index 6de8cb018d2..10a2c93946b 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/ShaderGUI/BaseShaderGUI.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGUI/BaseShaderGUI.cs @@ -903,8 +903,7 @@ public static void SetMaterialKeywords(Material material, Action shadi if (material.HasProperty(Property.EmissionColor)) MaterialEditor.FixupEmissiveFlag(material); - bool shouldEmissionBeEnabled = - (material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.EmissiveIsBlack) == 0; + bool shouldEmissionBeEnabled = (material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.AnyEmissive) != 0; // Not sure what this is used for, I don't see this property declared by any Unity shader in our repo... // I'm guessing it is some kind of legacy material upgrade support thing? Or maybe just dead code now... diff --git a/Packages/com.unity.render-pipelines.universal/Editor/UniversalRenderPipelineMaterialUpgrader.cs b/Packages/com.unity.render-pipelines.universal/Editor/UniversalRenderPipelineMaterialUpgrader.cs index 15f93c2d219..287c1658e2e 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/UniversalRenderPipelineMaterialUpgrader.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/UniversalRenderPipelineMaterialUpgrader.cs @@ -598,7 +598,7 @@ internal static void UpdateMaterialKeywords(Material material) // or is enabled and may be modified at runtime. This state depends on the values of the current flag and emissive color. // The fixup routine makes sure that the material is in the correct state if/when changes are made to the mode or color. MaterialEditor.FixupEmissiveFlag(material); - bool shouldEmissionBeEnabled = (material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.EmissiveIsBlack) == 0; + bool shouldEmissionBeEnabled = (material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.AnyEmissive) != 0; CoreUtils.SetKeyword(material, "_EMISSION", shouldEmissionBeEnabled); UniversalRenderPipelineMaterialUpgrader.DisableKeywords(material); } diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2D.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2D.cs index f94e4451e46..e1d36dc026a 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2D.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2D.cs @@ -3,6 +3,7 @@ using UnityEngine.Scripting.APIUpdating; using UnityEngine.U2D; using UnityEngine.Rendering.RenderGraphModule; +using System.Collections.Generic; #if UNITY_EDITOR using System.Linq; #endif @@ -180,7 +181,6 @@ private enum ComponentVersions // We use Blue Channel of LightMesh's vertex color to indicate Slot Index. int m_BatchSlotIndex = 0; internal int batchSlotIndex { get { return m_BatchSlotIndex; } set { m_BatchSlotIndex = value; } } - internal int[] affectedSortingLayers => m_ApplyToSortingLayers; private int lightCookieSpriteInstanceID => lightCookieSprite?.GetInstanceID() ?? 0; @@ -338,6 +338,96 @@ public LightType lightType ///
public bool renderVolumetricShadows => volumetricShadowsEnabled && shadowVolumeIntensity > 0; + /// + /// Gets or sets the target sorting layers for the light. Contains an array of sorting layer IDs. + /// + public int[] targetSortingLayers + { + get => m_ApplyToSortingLayers; + set + { + var layers = new List(); + foreach (var layerID in value) + { + if (SortingLayer.IsValid(layerID)) + layers.Add(layerID); + } + m_ApplyToSortingLayers = layers.ToArray(); + } + } + + bool IsValidLayer(string name) + { + // Have this check as SortingLayer.NameToID returns 0 (default layer) if layer is not found + foreach (var layer in Light2DManager.GetCachedSortingLayer()) + { + if (layer.name == name) + return true; + } + + return false; + } + + /// + /// Adds a target sorting layer to the light. + /// + /// The sorting layer name to be added. + /// Returns true if the sorting layer is added. Returns false if the layer name is invalid or has already been added. + public bool AddTargetSortingLayer(string layerName) + { + var layers = new List(m_ApplyToSortingLayers); + var id = SortingLayer.NameToID(layerName); + + // Invalid or duplicate layerID + if (!IsValidLayer(layerName) || layers.Contains(id)) + return false; + + layers.Add(id); + m_ApplyToSortingLayers = layers.ToArray(); + + return true; + } + + /// + /// Adds a target sorting layer to the light. + /// + /// The sorting layer ID to be added. + /// Returns true if the sorting layer is added. Returns false if the layer ID is invalid or has already been added. + public bool AddTargetSortingLayer(int layerID) + { + return AddTargetSortingLayer(SortingLayer.IDToName(layerID)); + } + + /// + /// Removes a target sorting layer from the light. + /// + /// The sorting layer name to be removed. + /// Returns true if the sorting layer is removed. Returns false if the layer name is invalid or doesn't exist. + public bool RemoveTargetSortingLayer(string layerName) + { + var layers = new List(m_ApplyToSortingLayers); + var id = SortingLayer.NameToID(layerName); + + // Invalid or layerID does not exist + if (!IsValidLayer(layerName) || !layers.Contains(id)) + return false; + + layers.Remove(id); + m_ApplyToSortingLayers = layers.ToArray(); + + return true; + } + + /// + /// Removes a target sorting layer from the light. + /// + /// The sorting layer ID to be removed. + /// Returns true if the sorting layer is removed. Returns false if the layer ID is invalid or doesn't exist. + public bool RemoveTargetSortingLayer(int layerID) + { + return RemoveTargetSortingLayer(SortingLayer.IDToName(layerID)); + } + internal void MarkForUpdate() { forceUpdate = true; diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2DManager.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2DManager.cs index 1fe354baf54..44d120fcbd7 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2DManager.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2DManager.cs @@ -42,7 +42,7 @@ public static void ErrorIfDuplicateGlobalLight(Light2D light) if (light.lightType != Light2D.LightType.Global) return; - foreach (var sortingLayer in light.affectedSortingLayers) + foreach (var sortingLayer in light.targetSortingLayers) { // should this really trigger at runtime? if (ContainsDuplicateGlobalLight(sortingLayer, light.blendStyleIndex)) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Materials/Decal.mat b/Packages/com.unity.render-pipelines.universal/Runtime/Materials/Decal.mat index 89081d863f4..304601ab7db 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Materials/Decal.mat +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Materials/Decal.mat @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} m_Name: m_EditorClassIdentifier: - version: 9 + version: 10 --- !u!21 &2100000 Material: serializedVersion: 8 @@ -140,3 +140,4 @@ Material: - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} m_BuildTextureStacks: [] + m_AllowLocking: 1 diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Materials/Lit.mat b/Packages/com.unity.render-pipelines.universal/Runtime/Materials/Lit.mat index 18f260d573b..86823912f59 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Materials/Lit.mat +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Materials/Lit.mat @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} m_Name: m_EditorClassIdentifier: - version: 9 + version: 10 --- !u!21 &2100000 Material: serializedVersion: 8 @@ -151,3 +151,4 @@ Material: - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _SpecColor: {r: 1, g: 1, b: 1, a: 1} m_BuildTextureStacks: [] + m_AllowLocking: 1 diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Materials/ParticlesUnlit.mat b/Packages/com.unity.render-pipelines.universal/Runtime/Materials/ParticlesUnlit.mat index 6e9d2852e77..f1f5bc98cbd 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Materials/ParticlesUnlit.mat +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Materials/ParticlesUnlit.mat @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} m_Name: m_EditorClassIdentifier: - version: 9 + version: 10 --- !u!21 &2100000 Material: serializedVersion: 8 @@ -136,3 +136,4 @@ Material: - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0} m_BuildTextureStacks: [] + m_AllowLocking: 1 diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Materials/SimpleLit.mat b/Packages/com.unity.render-pipelines.universal/Runtime/Materials/SimpleLit.mat index ff3d3f71f07..b866ab3a9f3 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Materials/SimpleLit.mat +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Materials/SimpleLit.mat @@ -116,6 +116,7 @@ Material: - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _SpecColor: {r: 0.5, g: 0.5, b: 0.5, a: 0.5} m_BuildTextureStacks: [] + m_AllowLocking: 1 --- !u!114 &2591765247069500558 MonoBehaviour: m_ObjectHideFlags: 11 @@ -128,4 +129,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} m_Name: m_EditorClassIdentifier: - version: 9 + version: 10 diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Materials/TerrainLit.mat b/Packages/com.unity.render-pipelines.universal/Runtime/Materials/TerrainLit.mat index 17746b80f73..6d13b0e0629 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Materials/TerrainLit.mat +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Materials/TerrainLit.mat @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} m_Name: m_EditorClassIdentifier: - version: 9 + version: 10 --- !u!21 &2100000 Material: serializedVersion: 8 @@ -171,3 +171,4 @@ Material: - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} m_BuildTextureStacks: [] + m_AllowLocking: 1 diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/InvokeOnRenderObjectCallbackPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/InvokeOnRenderObjectCallbackPass.cs index 690138f1f49..1ad8822288e 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/InvokeOnRenderObjectCallbackPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/InvokeOnRenderObjectCallbackPass.cs @@ -42,6 +42,7 @@ internal void Render(RenderGraph renderGraph, TextureHandle colorTarget, Texture builder.AllowPassCulling(false); builder.SetRenderFunc((PassData data, UnsafeGraphContext context) => { + context.cmd.SetRenderTarget(data.colorTarget, data.depthTarget); context.cmd.InvokeOnRenderObjectCallbacks(); }); } diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Settings/URPDefaultVolumeProfileSetting.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Settings/URPDefaultVolumeProfileSetting.cs index 37e250565eb..543687bd9e8 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Settings/URPDefaultVolumeProfileSetting.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Settings/URPDefaultVolumeProfileSetting.cs @@ -42,9 +42,9 @@ public VolumeProfile volumeProfile #if UNITY_EDITOR //Overriding "Reset" in menu that is not called at URPDefaultVolumeProfileSettings creation such Reset() - struct ResetImplementation : IRenderPipelineGraphicsSettingsContextMenu + struct ResetImplementation : IRenderPipelineGraphicsSettingsContextMenu2 { - public void PopulateContextMenu(URPDefaultVolumeProfileSettings setting, PropertyDrawer drawer, ref GenericMenu menu) + public void PopulateContextMenu(URPDefaultVolumeProfileSettings setting, SerializedProperty _, ref GenericMenu menu) { void Reset() { diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs index 422a6f0ea56..cfee97c99a7 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs @@ -522,6 +522,8 @@ void CreateRenderGraphCameraRenderTargets(RenderGraph renderGraph, bool isCamera importInfo.volumeDepth = cameraData.xr.renderTargetDesc.volumeDepth; importInfo.msaaSamples = cameraData.xr.renderTargetDesc.msaaSamples; importInfo.format = cameraData.xr.renderTargetDesc.graphicsFormat; + if (!PlatformRequiresExplicitMsaaResolve()) + importInfo.bindMS = importInfo.msaaSamples > 1; importInfoDepth = importInfo; importInfoDepth.format = cameraData.xr.renderTargetDesc.depthStencilFormat; diff --git a/Packages/com.unity.visualeffectgraph/Editor/Inspector/VFXSlotContainerEditor.cs b/Packages/com.unity.visualeffectgraph/Editor/Inspector/VFXSlotContainerEditor.cs index d8d93500869..8d59a88448a 100644 --- a/Packages/com.unity.visualeffectgraph/Editor/Inspector/VFXSlotContainerEditor.cs +++ b/Packages/com.unity.visualeffectgraph/Editor/Inspector/VFXSlotContainerEditor.cs @@ -442,6 +442,7 @@ static Styles() { VFXValueType.Int32, new Color32(125, 110, 191, 255) }, { VFXValueType.Matrix4x4, new Color32(118, 118, 118, 255) }, { VFXValueType.Mesh, new Color32(130, 223, 226, 255) }, + { VFXValueType.SkinnedMeshRenderer, new Color32(130, 223, 226, 255) }, { VFXValueType.None, new Color32(118, 118, 118, 255) }, { VFXValueType.Spline, new Color32(130, 223, 226, 255) }, { VFXValueType.Texture2D, new Color32(250, 137, 137, 255) }, diff --git a/Tests/SRPTests/Projects/SRP_SmokeTest/Assets/Tests/Editor/Volumes/VolumeComponentEditorSupportedOnTests.cs b/Tests/SRPTests/Projects/SRP_SmokeTest/Assets/Tests/Editor/Volumes/VolumeComponentEditorSupportedOnTests.cs index a0af00156dd..c92a3533127 100644 --- a/Tests/SRPTests/Projects/SRP_SmokeTest/Assets/Tests/Editor/Volumes/VolumeComponentEditorSupportedOnTests.cs +++ b/Tests/SRPTests/Projects/SRP_SmokeTest/Assets/Tests/Editor/Volumes/VolumeComponentEditorSupportedOnTests.cs @@ -34,12 +34,15 @@ public void TestVolumeManagerSupportedOnFiltering(Type renderPipelineAssetType, { var volumeManager = new VolumeManager(); volumeManager.LoadBaseTypes(renderPipelineAssetType); + volumeManager.InitializeInternal(); foreach (var expectedType in expectedTypes) Assert.That(() => volumeManager.baseComponentTypeArray.First(t => t == expectedType), Throws.Nothing); foreach (var notExpectedType in notExpectedTypes) Assert.That(() => volumeManager.baseComponentTypeArray.First(t => t == notExpectedType), Throws.InvalidOperationException); + + volumeManager.Deinitialize(); } } } diff --git a/Tests/SRPTests/Projects/SRP_SmokeTest/Assets/Tests/Editor/Volumes/VolumeComponentTests.cs b/Tests/SRPTests/Projects/SRP_SmokeTest/Assets/Tests/Editor/Volumes/VolumeComponentTests.cs index 088110455b6..5f891196eb1 100644 --- a/Tests/SRPTests/Projects/SRP_SmokeTest/Assets/Tests/Editor/Volumes/VolumeComponentTests.cs +++ b/Tests/SRPTests/Projects/SRP_SmokeTest/Assets/Tests/Editor/Volumes/VolumeComponentTests.cs @@ -1,5 +1,6 @@ using NUnit.Framework; using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -168,25 +169,20 @@ public void TearDown() { var vm = new VolumeManager(); vm.baseComponentTypeArray = new[] {typeof(TestAnimationCurveVolumeComponent)}; - vm.EvaluateVolumeDefaultState(); - - // Initialize the stack - var stack = vm.CreateStack(); + vm.InitializeInternal(); actionToPerform?.Invoke( - stack.parameters[0].GetValue(), // parameterInterpolated + vm.stack.parameters[0].GetValue(), // parameterInterpolated vm.m_ParametersDefaultState[0].GetValue(), // defaultParameterForFastAccess m_DefaultComponent.testParameter.GetValue(), // defaultComponentParameterUsedToInitializeStack - stack, + vm.stack, vm); - return ( - stack.parameters == null ? - -1 : stack.parameters[0].GetValue().length, // parameterInterpolated - vm.m_ParametersDefaultState == null ? - -1 : vm.m_ParametersDefaultState[0].GetValue().length, // defaultParameterForFastAccess - m_DefaultComponent.testParameter.GetValue().length // defaultComponentParameterUsedToInitializeStack - ); + var parameterInterpolated = vm.stack.parameters == null ? -1 : vm.stack.parameters[0].GetValue().length; + var defaultParameterForFastAccess = vm.m_ParametersDefaultState == null ? -1 : vm.m_ParametersDefaultState[0].GetValue().length; + var defaultComponentParameterUsedToInitializeStack = m_DefaultComponent.testParameter.GetValue().length; + vm.Deinitialize(); + return (parameterInterpolated, defaultParameterForFastAccess, defaultComponentParameterUsedToInitializeStack); } } diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Test/Runtime/Light2DTests.cs b/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Test/Runtime/Light2DTests.cs new file mode 100644 index 00000000000..2e71a1d3443 --- /dev/null +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Test/Runtime/Light2DTests.cs @@ -0,0 +1,94 @@ +using NUnit.Framework; +using UnityEngine; +using UnityEngine.Rendering.Universal; + +[TestFixture] +class Light2DTests +{ + GameObject m_BaseObj; + Light2D m_Light; + + [SetUp] + public void Setup() + { + m_BaseObj = new GameObject(); + m_Light = m_BaseObj.AddComponent(); + } + + [TearDown] + public void Cleanup() + { + Object.DestroyImmediate(m_BaseObj); + } + + [Test] + public void TargetSortingLayer_Getter() + { + Assert.IsNotNull(m_Light.targetSortingLayers); + Assert.IsNotEmpty(m_Light.targetSortingLayers); + } + + [Test] + public void TargetSortingLayer_Setter() + { + // Empty + m_Light.targetSortingLayers = new int[] { }; + Assert.IsEmpty(m_Light.targetSortingLayers); + + // Add default layer + m_Light.targetSortingLayers = new int[] { SortingLayer.NameToID("Default") }; + Assert.IsTrue(m_Light.targetSortingLayers.Length == 1); + } + + [Test] + public void TargetSortingLayer_IsValid() + { + foreach (var layer in m_Light.targetSortingLayers) + Assert.IsTrue(SortingLayer.IsValid(layer)); + } + + [Test] + public void TargetSortingLayer_AddValidLayer() + { + var layers = m_Light.targetSortingLayers; + + m_Light.targetSortingLayers = new int[] { }; + + // Add back layers + foreach (var layer in layers) + Assert.IsTrue(m_Light.AddTargetSortingLayer(layer)); + + Assert.IsTrue(m_Light.targetSortingLayers.Length == layers.Length); + } + + [Test] + public void TargetSortingLayer_AddInvalidLayer() + { + // Add an invalid layer returns false + Assert.IsFalse(m_Light.AddTargetSortingLayer("Invalid")); + // Add random layerID + Assert.IsFalse(m_Light.AddTargetSortingLayer(234393945)); + + } + + [Test] + public void TargetSortingLayer_RemoveValidLayer() + { + var layers = m_Light.targetSortingLayers; + + // Remove layers + foreach (var layer in layers) + Assert.IsTrue(m_Light.RemoveTargetSortingLayer(layer)); + + Assert.IsEmpty(m_Light.targetSortingLayers); + } + + [Test] + public void TargetSortingLayer_RemoveInvalidLayer() + { + // Remove an invalid layer returns false + Assert.IsFalse(m_Light.RemoveTargetSortingLayer("Invalid")); + // Remove random layerID + Assert.IsFalse(m_Light.AddTargetSortingLayer(234393945)); + } +} diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Test/Runtime/Light2DTests.cs.meta b/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Test/Runtime/Light2DTests.cs.meta new file mode 100644 index 00000000000..ab900818d29 --- /dev/null +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Test/Runtime/Light2DTests.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 5a8248559394daa439bca0885d1cbbb9 \ No newline at end of file diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Test/TestFilters/TestCaseFilters.asset b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Test/TestFilters/TestCaseFilters.asset index d09caf98a74..a6230ac9719 100644 --- a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Test/TestFilters/TestCaseFilters.asset +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Test/TestFilters/TestCaseFilters.asset @@ -1183,3 +1183,13 @@ MonoBehaviour: XrSdk: StereoModes: 0 Reason: Alembic package is desktop only + - FilteredScene: {fileID: 0} + FilteredScenes: + - {fileID: 102900000, guid: 7fd0aa748aac54e47a22af71a33c7af3, type: 3} + ColorSpace: -1 + BuildPlatform: -2 + GraphicsDevice: 18 + Architecture: 4 + XrSdk: + StereoModes: 0 + Reason: UUM-109556