diff --git a/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.uss b/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.uss index 2dd183f21ac..04cdd7e6368 100644 --- a/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.uss +++ b/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.uss @@ -63,13 +63,13 @@ .showEnvironmentPanel > #environmentContainer { - width: 249px; + width: 255px; visibility: visible; } .showDebugPanel > #debugContainer { - width: 250px; /*219px;*/ + width: 256px; /*219px;*/ visibility: visible; } @@ -322,9 +322,9 @@ MultipleSourcePopupField > MultipleDifferentValue:hover #tabsRadio { - width: 250px; - min-width: 250px; - max-width: 250px; + width: 256px; + min-width: 256px; + max-width: 256px; flex: 1; flex-direction: row; -unity-text-align: middle-center; diff --git a/com.unity.render-pipelines.core/Editor/LookDev/Stage.cs b/com.unity.render-pipelines.core/Editor/LookDev/Stage.cs index 0679af9f6f1..0f121b9bcbd 100644 --- a/com.unity.render-pipelines.core/Editor/LookDev/Stage.cs +++ b/com.unity.render-pipelines.core/Editor/LookDev/Stage.cs @@ -217,16 +217,28 @@ void SetGameObjectVisible(bool visible) if (go == null || go.Equals(null)) continue; foreach (UnityEngine.Renderer renderer in go.GetComponentsInChildren()) - renderer.enabled = visible; + { + if((renderer.hideFlags & HideFlags.HideInInspector) == 0 && ((renderer.hideFlags & HideFlags.HideAndDontSave) == 0)) + renderer.enabled = visible; + } foreach (Light light in go.GetComponentsInChildren()) - light.enabled = visible; + { + if ((light.hideFlags & HideFlags.HideInInspector) == 0 && ((light.hideFlags & HideFlags.HideAndDontSave) == 0)) + light.enabled = visible; + } } // in case we add camera frontal light and such foreach (UnityEngine.Renderer renderer in m_Camera.GetComponentsInChildren()) - renderer.enabled = visible; + { + if ((renderer.hideFlags & HideFlags.HideInInspector) == 0 && ((renderer.hideFlags & HideFlags.HideAndDontSave) == 0)) + renderer.enabled = visible; + } foreach (Light light in m_Camera.GetComponentsInChildren()) - light.enabled = visible; + { + if ((light.hideFlags & HideFlags.HideInInspector) == 0 && ((light.hideFlags & HideFlags.HideAndDontSave) == 0)) + light.enabled = visible; + } } public void OnBeginRendering(IDataProvider dataProvider) diff --git a/com.unity.render-pipelines.core/Runtime/Common/DynamicResolutionHandler.cs b/com.unity.render-pipelines.core/Runtime/Common/DynamicResolutionHandler.cs index e12557fc800..cfb34c728b5 100644 --- a/com.unity.render-pipelines.core/Runtime/Common/DynamicResolutionHandler.cs +++ b/com.unity.render-pipelines.core/Runtime/Common/DynamicResolutionHandler.cs @@ -159,7 +159,8 @@ public void Update(GlobalDynamicResolutionSettings settings, Action OnResolution ScalableBufferManager.ResizeBuffers(m_CurrentFraction, m_CurrentFraction); } - OnResolutionChange(); + if(OnResolutionChange != null) + OnResolutionChange(); } else { @@ -169,7 +170,8 @@ public void Update(GlobalDynamicResolutionSettings settings, Action OnResolution if(ScalableBufferManager.widthScaleFactor != m_PrevHWScaleWidth || ScalableBufferManager.heightScaleFactor != m_PrevHWScaleHeight) { - OnResolutionChange(); + if (OnResolutionChange != null) + OnResolutionChange(); } } } diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 710527d6bb8..2b5d6b71e5b 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -11,6 +11,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed a null ref exception when baking reflection probes. - Fixed TAA issue and hardware dynamic resolution. - Fixed an issue where look dev lighting would go black when a new scene is loaded. +- Fixed warning in HDAdditionalLightData OnValidate (cases 1250864, 1244578) +- Fixed sky asserts with XR multipass +- Fixed XR Display providers not getting zNear and zFar plane distances passed to them when in HDRP. +- Fixed issue that failed compilation when XR is disabled. +- Fixed issue with dynamic resolution handler when no OnResolutionChange callback is specified. +- Fixed error about layers when disabling emissive mesh for area lights. +- Fixed issue with sun icon being clipped in the look dev window. +- Fixed lookdev toggling renderers that are set to non editable or are hidden in the inspector. +- Fixed issue causing the editor field not updating the disc area light radius. +- Fixed an issue where only one of the two lookdev views would update when changing the default lookdev volume profile. +- Fixed issue that caused the decal atlas to not be updated upon changing of the decal textures content. +- Fixed "Screen position out of view frustum" error when camera is at exactly the planar reflection probe location. +- Fixed issue with diffusion profile not being updated upon reset of the editor. +- Fixed Amplitude -> Min/Max parametrization conversion + +### Changed +- Remove MSAA debug mode when renderpipeline asset has no MSAA +- Reduced the number of global keyword used in deferredTile.shader ## [8.2.0] - 2020-07-08 diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Autodesk-Interactive-Shader-Masked.md b/com.unity.render-pipelines.high-definition/Documentation~/Autodesk-Interactive-Shader-Masked.md new file mode 100644 index 00000000000..c615d6aff96 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/Autodesk-Interactive-Shader-Masked.md @@ -0,0 +1,50 @@ +# Autodesk Interactive masked shader + +The Autodesk Interactive masked shader replicates the Interactive PBS with the masked preset available in Autodesk® 3DsMax and Autodesk® Maya for the High Definition Render Pipeline (HDRP). It acts like a [cutout shader](https://docs.unity3d.com/Manual/shader-TransparentCutoutFamily.html). When Unity imports an FBX exported from one of these softwares, if the FBX includes materials with Interactive PBS shaders, Unity imports these materials as Autodesk Interactive materials. The material properties and textures inputs are identical between these two materials. The materials themselves also look and respond to light similarly. Note that there are slight differences between what you see in Autodesk® Maya or Autodesk® 3DsMax and what you see in Unity. + +Autodesk® Maya or Autodesk® 3DsMax also include two variants of this shader, which are also available in HDRP: + +- [Autodesk Interactive](Autodesk-Interactive-Shader.md) +- [Autodesk Interactive Transparent](Autodesk-Interactive-Shader-Transparent.md) + +Note that this shader is implemented as a [Shader Graph](https://docs.unity3d.com/Packages/com.unity.shadergraph@latest/index.html). + +## Creating an Autodesk Interactive masked material + +When Unity imports an FBX with a compatible Autodesk shader, it automatically creates an Autodesk Interactive material. If you want to manually create an Autodesk Interactive material: + +1. Create a new material (menu: **Assets > Create > Material**). +2. In the Inspector for the Material, click the **Shader** drop-down then click **HDRP > Autodesk Interactive > AutodeskInteractiveMasked**. + +### Properties + + + + + + +[!include[](snippets/shader-properties-uxml/autodesk-interactive/use-color-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/base-color.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/color-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/use-normal-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/normal-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/use-metallic-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/metallic.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/metallic-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/use-roughness-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/roughness.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/roughness-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/use-emissive-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/emissive.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/emissive-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/use-opacity-map(mask).md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/mask-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/mask-threshold.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/uv-offset.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/uv-scale.md)] +[!include[](snippets/shader-properties-uxml/general/enable-gpu-instancing.md)] +[!include[](snippets/shader-properties-uxml/general/double-sided-global-illumination.md)] +[!include[](snippets/shader-properties-uxml/general/emission.md)] +[!include[](snippets/shader-properties-uxml/general/emission-global-illumination.md)] +[!include[](snippets/shader-properties-uxml/general/motion-vector-for-vertex-animation.md)] +
PropertyDescription
\ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Autodesk-Interactive-Shader-Transparent.md b/com.unity.render-pipelines.high-definition/Documentation~/Autodesk-Interactive-Shader-Transparent.md new file mode 100644 index 00000000000..72915a52b18 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/Autodesk-Interactive-Shader-Transparent.md @@ -0,0 +1,49 @@ +# Autodesk Interactive transparent shader + +The Autodesk Interactive transparent shader replicates the Interactive PBS with the transparent preset available in Autodesk® 3DsMax and Autodesk® Maya for the High Definition Render Pipeline (HDRP). When Unity imports an FBX exported from one of these softwares, if the FBX includes materials with Interactive PBS shaders, Unity imports these materials as Autodesk Interactive materials. The material properties and textures inputs are identical between these two materials. The materials themselves also look and respond to light similarly. Note that there are slight differences between what you see in Autodesk® Maya or Autodesk® 3DsMax and what you see in Unity. + +Autodesk® Maya or Autodesk® 3DsMax also include two variants of this shader, which are also available in HDRP: + +- [Autodesk Interactive](Autodesk-Interactive-Shader.md) +- [Autodesk Interactive Masked](Autodesk-Interactive-Shader-Masked.md) + +Note that this shader is implemented as a [Shader Graph](https://docs.unity3d.com/Packages/com.unity.shadergraph@latest/index.html). + +## Creating an Autodesk Interactive transparent material + +When Unity imports an FBX with a compatible Autodesk shader, it automatically creates an Autodesk Interactive material. If you want to manually create an Autodesk Interactive material: + +1. Create a new material (menu: **Assets > Create > Material**). +2. In the Inspector for the Material, click the **Shader** drop-down then click **HDRP > Autodesk Interactive > AutodeskInteractiveTransparent**. + +### Properties + + + + + + +[!include[](snippets/shader-properties-uxml/autodesk-interactive/use-color-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/base-color.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/color-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/use-normal-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/normal-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/use-metallic-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/metallic.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/metallic-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/use-roughness-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/roughness.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/roughness-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/use-emissive-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/emissive.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/emissive-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/use-opacity-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/opacity.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/uv-offset.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/uv-scale.md)] +[!include[](snippets/shader-properties-uxml/general/enable-gpu-instancing.md)] +[!include[](snippets/shader-properties-uxml/general/double-sided-global-illumination.md)] +[!include[](snippets/shader-properties-uxml/general/emission.md)] +[!include[](snippets/shader-properties-uxml/general/emission-global-illumination.md)] +[!include[](snippets/shader-properties-uxml/general/motion-vector-for-vertex-animation.md)] +
PropertyDescription
\ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Autodesk-Interactive-Shader.md b/com.unity.render-pipelines.high-definition/Documentation~/Autodesk-Interactive-Shader.md new file mode 100644 index 00000000000..220653a6529 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/Autodesk-Interactive-Shader.md @@ -0,0 +1,49 @@ +# Autodesk Interactive shader + +The Autodesk Interactive shader replicates the Interactive PBS available in Autodesk® 3DsMax and Autodesk® Maya for the High Definition Render Pipeline (HDRP). When Unity imports an FBX exported from one of these softwares, if the FBX includes materials with Interactive PBS shaders, Unity imports these materials as Autodesk Interactive materials. The material properties and textures inputs are identical between these two materials. The materials themselves also look and respond to light similarly. Note that there are slight differences between what you see in Autodesk® Maya or Autodesk® 3DsMax and what you see in Unity. + +Autodesk® Maya or Autodesk® 3DsMax also include two variants of this shader, which are also available in HDRP: + +- [Autodesk Interactive Masked](Autodesk-Interactive-Shader-Masked.md) +- [Autodesk Interactive Transparent](Autodesk-Interactive-Shader-Transparent.md) + +Note that this shader is implemented as a [Shader Graph](https://docs.unity3d.com/Packages/com.unity.shadergraph@latest/index.html). + +## Creating an Autodesk Interactive material + +When Unity imports an FBX with a compatible Autodesk shader, it automatically creates an Autodesk Interactive material. If you want to manually create an Autodesk Interactive material: + +1. Create a new material (menu: **Assets > Create > Material**). +2. In the Inspector for the Material, click the **Shader** drop-down then click **HDRP > Autodesk Interactive > AutodeskInteractive**. + +### Properties + + + + + + +[!include[](snippets/shader-properties-uxml/autodesk-interactive/use-color-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/base-color.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/color-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/use-normal-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/normal-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/use-metallic-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/metallic.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/metallic-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/use-roughness-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/roughness.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/roughness-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/use-emissive-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/emissive.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/emissive-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/use-ao-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/ao-map.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/uv-offset.md)] +[!include[](snippets/shader-properties-uxml/autodesk-interactive/uv-scale.md)] +[!include[](snippets/shader-properties-uxml/general/enable-gpu-instancing.md)] +[!include[](snippets/shader-properties-uxml/general/double-sided-global-illumination.md)] +[!include[](snippets/shader-properties-uxml/general/emission.md)] +[!include[](snippets/shader-properties-uxml/general/emission-global-illumination.md)] +[!include[](snippets/shader-properties-uxml/general/motion-vector-for-vertex-animation.md)] +
PropertyDescription
\ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/AxF-Shader.md b/com.unity.render-pipelines.high-definition/Documentation~/AxF-Shader.md index 795ed6788ab..9bd2f2dbfc9 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/AxF-Shader.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/AxF-Shader.md @@ -113,5 +113,5 @@ Note: The AxF Importer imports every Texture as half float, linear, sRGB gamut ( | **Property** | **Description** | | ---------------------------- | ------------------------------------------------------------ | -| **Enable GPU instancing** | Enable the checkbox to tell HDRP to render Meshes with the same geometry and Material in one batch when possible. This makes rendering faster. HDRP cannot render Meshes in one batch if they have different Materials, or if the hardware does not support GPU instancing. For example, you can not[ static-batch](https://docs.unity3d.com/Manual/DrawCallBatching.html) GameObjects that have an animation based on the object pivot, but the GPU can instance them. | +| **Enable GPU instancing** | Enable the checkbox to tell HDRP to render Meshes with the same geometry and Material in one batch when possible. This makes rendering faster. HDRP cannot render Meshes in one batch if they have different Materials, or if the hardware does not support GPU instancing. For example, you cannot [static-batch](https://docs.unity3d.com/Manual/DrawCallBatching.html) GameObjects that have an animation based on the object pivot, but the GPU can instance them. | | **Add Precomputed Velocity** | Enable the checkbox to use precomputed velocity information stored in an Alembic file. | \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Customizing-HDRP-materials-with-Shader-Graph.md b/com.unity.render-pipelines.high-definition/Documentation~/Customizing-HDRP-materials-with-Shader-Graph.md index ec884cc10df..e19648ae443 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Customizing-HDRP-materials-with-Shader-Graph.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Customizing-HDRP-materials-with-Shader-Graph.md @@ -36,8 +36,8 @@ To create a Material that uses a Shader Graph (for example, a StackLit Graph), f To edit properties for Materials that use Shader Graphs, the Inspector window only allows access to a limited number of properties. To edit all Material properties, you must directly edit the Shader Graph's Master Node. 1. Double-click on the Shader Graph Asset to open it. The window displays the Master Node and a list of the available inputs. See these in the **Surface Inputs** section of the screenshot below. -2. To expose the rest of the properties, click on the cog in the top right of the Master Node. See these other properties in the **Surface Options** section of the screenshot below. -3. Edit the values for the cog's properties in the same way as you would do in the Inspector window. The list of inputs on the Master Node, and the available properties in the cog's list, changes depending on what options you select. +2. To expose the rest of the properties, click on the gear in the top right of the Master Node. See these other properties in the **Surface Options** section of the screenshot below. +3. Edit the values for the gear's properties in the same way as you would do in the Inspector window. The list of inputs on the Master Node, and the available properties in the gear's list, changes depending on what options you select. ![](Images/CreatingAndEditingHDRPShaderGraphs1.png) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Dynamic-Resolution.md b/com.unity.render-pipelines.high-definition/Documentation~/Dynamic-Resolution.md index adcb2f9f444..b75534b8966 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Dynamic-Resolution.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Dynamic-Resolution.md @@ -1,16 +1,18 @@ # Dynamic resolution -Dynamic resolution reduces the workload on the GPU, which helps maintain a stable target frame rate. The High Definition Render Pipeline (HDRP) uses dynamic resolution to lower the resolution of the render targets that the main rendering passes use. HDRP will use hardware dynamic resolution when supported by the platform, otherwise it will use a software version. +Dynamic resolution reduces the workload on the GPU, which helps maintain a stable target frame rate. The High Definition Render Pipeline (HDRP) uses dynamic resolution to lower the resolution of the render targets that the main rendering passes use. To do this, HDRP uses hardware dynamic resolution, if the platform supports it, otherwise it uses a software version. The main difference is that, for hardware dynamic resolution, the hardware treats the render targets up until the back buffer as being of the scaled size. This means that is is faster to clear the render targets. -To use dynamic resolution in your Project, you must enable dynamic resolution in your [HDRP Asset)(HDRP-Asset.html). In the Inspector for your HDRP Asset, navigate to **Rendering** **> Dynamic Resolution** and enable the **Enable** checkbox. For information on how to customize the rest of the HDRP Asset’s global dynamic resolution properties, see the dynamic resolution section of the [HDRP Asset documentation](HDRP-Asset.html#DynamicResolution). -Moreover, each camera that needs to perform dynamic resolution needs to have the checkbox **General > Allow Dynamic Resolution** set on the camera component. - -When you enable dynamic resolution, HDRP allocates render targets to accommodate the maximum resolution possible. Then, HDRP rescales the viewport accordingly, so it can render at varying resolutions. At the end of each frame, HDRP upscales the result of the scaled rendering to match the back buffer resolution. To do this, HDRP uses the method defined in the **Upscale Filter**. +When you enable dynamic resolution, HDRP allocates render targets to accommodate the maximum resolution possible. Then, HDRP rescales the viewport accordingly, so it can render at varying resolutions. At the end of each frame, HDRP upscales the result of the scaled rendering to match the back buffer resolution. Regardless of which method HDRP uses to process dynamic resolution, either hardware or software, it still uses a software method to upscale the result. The method HDRP uses is defined in the **Upscale Filter**. ![](Images/DynamicResolution1.png) ## Using dynamic resolution +To use dynamic resolution in your Project, you must enable dynamic resolution in your [HDRP Asset](HDRP-Asset.md) and then enable it for each [Camera](HDRP-Camera.md) you want to use it with. To do this: + +1. In the Inspector for your HDRP Asset, go to **Rendering** **> Dynamic Resolution** and enable the **Enable** checkbox. For information on how to customize the rest of the HDRP Asset’s global dynamic resolution properties, see the dynamic resolution section of the [HDRP Asset documentation](HDRP-Asset.md#DynamicResolution). +2. For every [Camera](HDRP-Camera.md) you want to perform dynamic resolution, go to the **General** section and enable **Allow Dynamic Resolution**. + Dynamic resolution is not automatic, so you need to manually call the `DynamicResolutionHandler.SetDynamicResScaler(PerformDynamicRes scaler, DynamicResScalePolicyType scalerType)` function. The policy type can be one of the following: diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Environment-Lighting.md b/com.unity.render-pipelines.high-definition/Documentation~/Environment-Lighting.md index 107fef2bdb6..3d825fe4dc8 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Environment-Lighting.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Environment-Lighting.md @@ -3,40 +3,38 @@ Environment lighting allows you to simulate lighting coming from the surroundings of your Scene. It is common to use environment lighting to simulate sky lighting, but you can also use it to simulate a colored ambient light, or a lighting studio. In the High Definition Render Pipeline (HDRP), there are two parts to environment lighting: -* The visual environment, controlled by the [Visual Environment Volume override](Override-Visual-Environment.html). This controls the skybox that you can see through the Camera. With the[ built-in render pipeline](https://docs.unity3d.com/Manual/SL-RenderPipeline.html), you customize visual environment lighting settings on a per-Scene basis. In contrast, HDRP's Visual Environment uses the Volume framework to smoothly interpolate between different sets of environment lighting settings for your sky (and fog) within the same Scene. +* The visual environment, controlled by the [Visual Environment Volume override](Override-Visual-Environment.md). This controls the skybox that you can see through the Camera and represents the visual side of the environment lighting. With the[ built-in render pipeline](https://docs.unity3d.com/Manual/SL-RenderPipeline.html), you customize visual environment lighting settings on a per-Scene basis. In contrast, HDRP's Visual Environment uses the [Volume](Volumes.md) framework to smoothly interpolate between different sets of environment lighting settings for your sky (and fog) within the same Scene. +* The lighting environment, controlled by the **Environment (HDRP)** section of the Lighting window. HDRP uses the lighting environment to calculate indirect ambient lighting for your Scene. It does not use the Volume framework as HDRP's indirect ambient lighting currently only supports one source of environment lighting. -* The Lighting Environment, controlled by the **Environment (HDRP)** section of the Lighting window. This controls the sky that affects Global Illumination. It does not use the Volume framework as HDRP's Global Illumination currently only supports one source of environment lighting. +Essentially, you use the visual environment to control how the sky looks in your Scene and use the lighting environment to control how the sky contributes to indirect ambient lighting. ## Visual Environment -The Visual Environment is a Volume override that tells HDRP what type of [sky](HDRP-Features.html#SkyOverview) and [fog](HDRP-Features.html#FogOverview) you want to see through Cameras that the Volume affects. For information on how to customize Visual Environments, see the [Visual Environment](Override-Visual-Environment.html) documentation. +The Visual Environment is a Volume override that tells HDRP what type of [sky](HDRP-Features.md#SkyOverview) and [fog](HDRP-Features.md#FogOverview) you want to see through Cameras that the Volume affects. For information on how to customize Visual Environments, see the [Visual Environment](Override-Visual-Environment.md) documentation. -Your Unity Project’s [HDRP Asset](HDRP-Asset.html) has the following properties that also affect all Visual Environments: +Your Unity Project’s [HDRP Asset](HDRP-Asset.md) has the following properties that also affect all Visual Environments: * **Reflection Size**: Controls the resolution of the sky cube map. Unity uses this cube map as a fallback Reflection Probe for areas that local Reflection Probes do not affect. It has no effect on the quality of the sky directly seen through the camera. * **Lighting Override Mask**: A LayerMask that allows you to decouple the sky seen through the Camera from the one that affects the ambient lighting. For example, you might want a dark sky at night time, but to have brighter lighting so that you can still see clearly. See [Decoupling the visual environment from the lighting environment](#DecoupleVisualEnvironment). - - -## Ambient Light Probe +### HDRP built-in sky types -HDRP uses the ambient Light Probe as the final fallback for indirect diffuse lighting. It affects: +HDRP has three built-in [sky types](HDRP-Features.md#SkyOverview): -* All Mesh Renderers if there is no Global Illumination computed for the Scene (this applies when Unity has not computed any lightmaps or Light Probes for the Scene) -* Mesh Renderers that have their **Light Probe Mode** set to **Off** +* [HDRI Sky](Override-HDRI-Sky.md) +* [Gradient Sky](Override-Gradient-Sky.md) +* [Physically Based Sky](Override-Physically-Based-Sky.md) -* Volumetric fog if the Global Light Probe dimmer is set to a value above 0 +HDRP also allows you to implement your own sky types that display a background and handle environment lighting. See the [Customizing HDRP](Creating-a-Custom-Sky.md) documentation for instructions on how to implement your own sky. -The ambient Light Probe can be static (generated only once) or dynamic (updated at runtime).**Note**: If there is a **Light Probe group** in your Scene and you have computed **Global Illumination**, then the Ambient Light Probe only affects Mesh Renderers that have their **Light Probe Mode** set to **Off**, and that have **Volumetric fog** (if it’s enabled in the Scene). +**Note**: The **Procedural Sky** is deprecated and no longer built into HDRP. For information on how to add Procedural Sky to your HDRP Project, see the [Upgrading from 2019.2 to 2019.3 guide](Upgrading-From-2019.2-to-2019.3.md#ProceduralSky). -## Ambient Reflection Probe -HDRP uses the ambient Reflection Probe as a fallback for indirect specular lighting. This means that it only affects areas that local Reflection Probes, Screen Space Reflection, and raytraced reflections do not affect. ## Lighting environment -The **Environment (HDRP)** is a section in the Lighting window that allows you to specify which sky to use for Global Illumination. To open the window, select **Window > Lighting Settings**. +The **Environment (HDRP)** is a section in the Lighting window that allows you to specify which sky to use for indirect ambient light. To open the window, select **Window > Lighting Settings**. ![](Images/EnvironmentLighting1.png) @@ -44,8 +42,8 @@ The **Environment (HDRP)** section is at the top and has two settings that you c | **Setting** | **Description** | | ----------------------- | ------------------------------------------------------------ | -| **Profile** | A [Volume Profile](Volume-Profile.html) for the sky. This Volume Profile must include at least one Sky Volume override. | -| **Static Lighting Sky** | The sky to use for the Global Illumination simulation. The drop-down only contains sky types that the **Profile** includes. For example, if the **Profile** includes a **Gradient Sky** Volume override, you can select **Gradient Sky** from this drop-down.
You can only edit this setting if you assign a Volume Profile to the **Profile** field. | +| **Profile** | A [Volume Profile](Volume-Profile.md) for the sky. This Volume Profile must include at least one Sky Volume override. | +| **Static Lighting Sky** | The sky to use for the indirect ambient light simulation. The drop-down only contains sky types included and activated in the **Profile**. For example, if the **Profile** has an active **Gradient Sky** Volume override, you can select **Gradient Sky** from this drop-down.
If the **Profile** includes an active **Cloud Layer** Volume override, it contributes to indirect ambient light.
You can only edit this setting if you assign a Volume Profile to the **Profile** field and that **Profile** contains at least one active Sky Volume Override. | You can assign the same Volume Profile to both the **Static Lighting Sky** field and a Volume in your Scene. If you do this, and use the same sky settings for the baked lighting and the visual background in the Volume, the baked lighting accurately matches the background at runtime. If you want to control the light baking for the environment lighting separately to the visual background in your Scene, you can assign a different Volume Profile for each process. @@ -59,17 +57,20 @@ You can use the sky **Lighting Override Mask** in your Unity Project’s HDRP As An example of where you would want to decouple the sky lighting from the visual sky, and use a different Volume Profile for each, is when you have an [HDRI Sky](Override-HDRI-Sky.html) that includes sunlight. To make the sun visible at runtime in your application, your sky background must show an HDRI sky that features the sun. To achieve real-time lighting from the sun, you must use a Directional [Light](Light-Component.html) in your Scene and, for the baking process, use an HDRI sky that is identical to the first one but does not include the sun. If you were to use an HDRI sky that includes the sun to bake the lighting, the sun would contribute to the lighting twice (once from the Directional Light, and once from the baking process) and make the lighting look unrealistic. -## HDRP built-in sky types +## Ambient Light Probe + +HDRP uses the ambient Light Probe as the final fallback for indirect diffuse lighting. It affects: -HDRP has three built-in [sky types](HDRP-Features.html#SkyOverview): +- All Mesh Renderers if there is no indirect ambient light computed for the Scene (this applies when Unity has not computed any lightmaps or Light Probes for the Scene) +- Mesh Renderers that have their **Light Probe Mode** set to **Off** +- Volumetric fog if the Global Light Probe dimmer is set to a value above 0 -* [HDRI Sky](Override-HDRI-Sky.html) -* [Gradient Sky](Override-Gradient-Sky.html) -* [Physically Based Sky](Override-Physically-Based-Sky.html) +The ambient Light Probe can be static (generated only once) or dynamic (updated at runtime).**Note**: If there is a **Light Probe group** in your Scene and you have computed indirect ambient lighting, then the Ambient Light Probe only affects Mesh Renderers that have their **Light Probe Mode** set to **Off**, and that have **Volumetric fog** (if it’s enabled in the Scene). -HDRP also allows you to implement your own sky types that display a background and handle environment lighting. See the [Customizing HDRP](Creating-a-Custom-Sky.html) documentation for instructions on how to implement your own sky. +## Ambient Reflection Probe + +HDRP uses the ambient Reflection Probe as a fallback for indirect specular lighting. This means that it only affects areas that local Reflection Probes, Screen Space Reflection, and raytraced reflections do not affect. -**Note**: The **Procedural Sky** is deprecated and no longer built into HDRP. For information on how to add Procedural Sky to your HDRP Project, see the [Upgrading from 2019.2 to 2019.3 guide](Upgrading-From-2019.2-to-2019.3.html#ProceduralSky). ## Reflection diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/Override-HDRISky1.png b/com.unity.render-pipelines.high-definition/Documentation~/Images/Override-HDRISky1.png index fc884ce45fb..5e342987890 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Images/Override-HDRISky1.png +++ b/com.unity.render-pipelines.high-definition/Documentation~/Images/Override-HDRISky1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ba3c5657e8b360b4c34c8b71ec9fd424983a9f07e8672bbacf6ed6c8070e2739 -size 11230 +oid sha256:3d2f2dfcbc69f52225c5ba822495e5b6208dc7a60aacd09acdc2b74a190596ce +size 10626 diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/Post-processingPropagatingNaNsExample1.png b/com.unity.render-pipelines.high-definition/Documentation~/Images/Post-processingPropagatingNaNsExample1.png new file mode 100644 index 00000000000..59f292c06a1 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/Images/Post-processingPropagatingNaNsExample1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:79606421312be0ea846b6c4d34634af028614814afb851e7ea56a4fc02889b91 +size 78452 diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/Post-processingPropagatingNaNsExample2.png b/com.unity.render-pipelines.high-definition/Documentation~/Images/Post-processingPropagatingNaNsExample2.png new file mode 100644 index 00000000000..88c65cbf9d0 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/Images/Post-processingPropagatingNaNsExample2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4d3624a6122f656f325e94edd15e7a41331c5de47379e4dcb12b15a969f53e06 +size 73030 diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/Post-processingPropagatingNaNsExample3.png b/com.unity.render-pipelines.high-definition/Documentation~/Images/Post-processingPropagatingNaNsExample3.png new file mode 100644 index 00000000000..c3cf5e97282 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/Images/Post-processingPropagatingNaNsExample3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b981009b23fcb616c3b6ecd91187625c7c290ed4eb06d77cf76207c8d475e1fc +size 40226 diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/Post-processingPropagatingNaNsExample4.png b/com.unity.render-pipelines.high-definition/Documentation~/Images/Post-processingPropagatingNaNsExample4.png new file mode 100644 index 00000000000..e46e5be1da3 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/Images/Post-processingPropagatingNaNsExample4.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4ef7eae9f5804322d5b16dc31a717ea6294c2d504eafc834f442ca468c190683 +size 1098 diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/Post-processingPropagatingNaNsRenderDoc.png b/com.unity.render-pipelines.high-definition/Documentation~/Images/Post-processingPropagatingNaNsRenderDoc.png new file mode 100644 index 00000000000..e0fe1dae2c3 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/Images/Post-processingPropagatingNaNsRenderDoc.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:39323fd338e889c053859686d797d982870e34e13b622da572b08aa83abb6058 +size 6481 diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Layered-Lit-Shader.md b/com.unity.render-pipelines.high-definition/Documentation~/Layered-Lit-Shader.md index 59be04128ff..77ad0b3375c 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Layered-Lit-Shader.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Layered-Lit-Shader.md @@ -131,12 +131,12 @@ Unity exposes up to four Material layers for you to use in your Layered Material | **Emission Intensity** | Set the overall strength of the emission effect for this Material.Use the drop-down to select one of the following [physical light units](Physical-Light-Units.html) to use for intensity:• [Nits](Physical-Light-Units.html#Nits)• [EV100](Physical-Light-Units.html#EV) | | **Exposure Weight** | Use the slider to set how much effect the exposure has on the emission power. For example, if you create a neon tube, you would want to apply the emissive glow effect at every exposure. | | **Emission Multiply with Base** | Enable the checkbox to make HDRP use the base color of the Material when it calculates the final color of the emission. When enabled, HDRP multiplies the emission color by the base color to calculate the final emission color. | -| **Emission** | Enable the checkbox to make the emission color affect global illumination. | -| **- Global Illumination** | Use the drop-down to choose how color emission interacts with global illumination.• **Realtime**: Select this option to make emission affect the result of real-time global illumination.• **Baked**: Select this option to make emission only affect global illumination during the baking process.• **None**: Select this option to make emission not affect global illumination. | +| **Emission** | Toggles whether emission affects global illumination. | +| **- Global Illumination** | The mode HDRP uses to determine how color emission interacts with global illumination.
• **Realtime**: Select this option to make emission affect the result of real-time global illumination.
• **Baked**: Select this option to make emission only affect global illumination during the baking process.
• **None**: Select this option to make emission not affect global illumination. | ### Advanced Options | **Property** | **Description** | | --------------------------------------- | ------------------------------------------------------------ | -| **Enable GPU instancing** | Enable the checkbox to tell HDRP to render Meshes with the same geometry and Material in one batch when possible. This makes rendering faster. HDRP cannot render Meshes in one batch if they have different Materials, or if the hardware does not support GPU instancing. For example, you can not [static-batch](https://docs.unity3d.com/Manual/DrawCallBatching.html) GameObjects that have an animation based on the object pivot, but the GPU can instance them. | +| **Enable GPU instancing** | Enable the checkbox to tell HDRP to render Meshes with the same geometry and Material in one batch when possible. This makes rendering faster. HDRP cannot render Meshes in one batch if they have different Materials, or if the hardware does not support GPU instancing. For example, you cannot [static-batch](https://docs.unity3d.com/Manual/DrawCallBatching.html) GameObjects that have an animation based on the object pivot, but the GPU can instance them. | | **Specular Occlusion from Bent normal** | Enable the checkbox to make HDRP use the Bent Normal Map to process specular occlusion for Reflection Probes. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Lit-Shader.md b/com.unity.render-pipelines.high-definition/Documentation~/Lit-Shader.md index 28a8fb207c0..81e811805f9 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Lit-Shader.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Lit-Shader.md @@ -83,8 +83,8 @@ Unity exposes this section if you select **Transparent** from the **Surface Type | **Emission Intensity** | Set the overall strength of the emission effect for this Material.
Use the drop-down to select one of the following [physical light units](Physical-Light-Units.html) to use for intensity:
• [Nits](Physical-Light-Units.html#Nits)
• [EV100](Physical-Light-Units.html#EV) | | **Exposure Weight** | Use the slider to set how much effect the exposure has on the emission power. For example, if you create a neon tube, you would want to apply the emissive glow effect at every exposure. | | **Emission Multiply with Base** | Enable the checkbox to make HDRP use the base color of the Material when it calculates the final color of the emission. When enabled, HDRP multiplies the emission color by the base color to calculate the final emission color. | -| **Emission** | Enable the checkbox to make the emission color affect global illumination. | -| **- Global Illumination** | Use the drop-down to choose how color emission interacts with global illumination.
• **Realtime**: Select this option to make emission affect the result of real-time global illumination.
• **Baked**: Select this option to make emission only affect global illumination during the baking process.
• **None**: Select this option to make emission not affect global illumination. | +| **Emission** | Toggles whether emission affects global illumination. | +| **- Global Illumination** | The mode HDRP uses to determine how color emission interacts with global illumination.
• **Realtime**: Select this option to make emission affect the result of real-time global illumination.
• **Baked**: Select this option to make emission only affect global illumination during the baking process.
• **None**: Select this option to make emission not affect global illumination. | ### Advanced options diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Lit-Tessellation-Shader.md b/com.unity.render-pipelines.high-definition/Documentation~/Lit-Tessellation-Shader.md index ed1011652be..9f15376557c 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Lit-Tessellation-Shader.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Lit-Tessellation-Shader.md @@ -100,8 +100,8 @@ Unity exposes this section if you select **Transparent** from the **Surface Type | **Emission Intensity** | Set the overall strength of the emission effect for this Material.
Use the drop-down to select one of the following [physical light units](Physical-Light-Units.html) to use for intensity:
• [Nits](Physical-Light-Units.html#Nits)
• [EV100](Physical-Light-Units.html#EV) | | **Exposure Weight** | Use the slider to set how much effect the exposure has on the emission power. For example, if you create a neon tube, you would want to apply the emissive glow effect at every exposure. | | **Emission Multiply with Base** | Enable the checkbox to make HDRP use the base color of the Material when it calculates the final color of the emission. When enabled, HDRP multiplies the emission color by the base color to calculate the final emission color. | -| **Emission** | Enable the checkbox to make the emission color affect global illumination. | -| **- Global Illumination** | Use the drop-down to choose how color emission interacts with global illumination.
• **Realtime**: Select this option to make emission affect the result of real-time global illumination.
• **Baked**: Select this option to make emission only affect global illumination during the baking process.
• **None**: Select this option to make emission not affect global illumination. | +| **Emission** | Toggles whether emission affects global illumination. | +| **- Global Illumination** | The mode HDRP uses to determine how color emission interacts with global illumination.
• **Realtime**: Select this option to make emission affect the result of real-time global illumination.
• **Baked**: Select this option to make emission only affect global illumination during the baking process.
• **None**: Select this option to make emission not affect global illumination. | ### Advanced options diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Decal.md b/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Decal.md index 6a20168dd96..01d78e37993 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Decal.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Decal.md @@ -42,7 +42,7 @@ The following table describes the input ports on a Decal Master Node, including ### Master Node settings menu -To view these properties, click the **Cog** in the top right of the Master Node. +To view these properties, click the gear in the top right of the Master Node. ![](Images/MasterNodeDecal2.png)) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Fabric.md b/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Fabric.md index 52ec484c2af..d0872be40a4 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Fabric.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Fabric.md @@ -94,7 +94,7 @@ These properties are in the **Exposed Properties** section of the Inspector, alo | **Property** | **Description** | | -------------------------------------- | ------------------------------------------------------------ | -| **Enable GPU Instancing** | Enable this setting to tell HDRP to render Meshes with the same geometry and Material in one batch when possible. This makes rendering faster. HDRP cannot render Meshes in one batch if they have different Materials, or if the hardware does not support GPU instancing. For example, you cannot [static-batch](https://docs.unity3d.com/Manual/DrawCallBatching.html) GameObjects that have an animation based on the object pivot, but the GPU can instance them. | -| **Emission** | Defines the Material's emission color value. Expects positive values. | -| **- Global Illumination** | Allows the user to specify what input should be used for the global illumination.
• **Realtime**: Select this option to make emission affect the result of real-time global illumination.
• **Baked**: Select this option to make emission only affect global illumination during the baking process.
• **None**: Select this option to make emission not affect global illumination. | -| **Motion Vector For Vertex Animation** | Indicates whether HDRP should evaluate motion vectors for animation. | \ No newline at end of file +| **Enable GPU Instancing** | Enable the checkbox to tell HDRP to render Meshes with the same geometry and Material in one batch when possible. This makes rendering faster. HDRP cannot render Meshes in one batch if they have different Materials, or if the hardware does not support GPU instancing. For example, you cannot [static-batch](https://docs.unity3d.com/Manual/DrawCallBatching.html) GameObjects that have an animation based on the object pivot, but the GPU can instance them. | +| **Emission** | Toggles whether emission affects global illumination. | +| **- Global Illumination** | The mode HDRP uses to determine how color emission interacts with global illumination.
• **Realtime**: Select this option to make emission affect the result of real-time global illumination.
• **Baked**: Select this option to make emission only affect global illumination during the baking process.
• **None**: Select this option to make emission not affect global illumination. | +| **Motion Vector For Vertex Animation** | Enable the checkbox to make HDRP write motion vectors for GameObjects that use vertex animation. This removes the ghosting that vertex animation can cause. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Hair.md b/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Hair.md index f4843632c6c..a8035732e12 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Hair.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Hair.md @@ -89,7 +89,7 @@ These properties are in the **Exposed Properties** section of the Inspector and | **Property** | **Description** | | -------------------------------------- | ------------------------------------------------------------ | -| **Enable GPU Instancing** | Enable this setting to tell HDRP to render Meshes with the same geometry and Material in one batch when possible. This makes rendering faster. HDRP cannot render Meshes in one batch if they have different Materials, or if the hardware does not support GPU instancing. For example, you cannot [static-batch](https://docs.unity3d.com/Manual/DrawCallBatching.html) GameObjects that have an animation based on the object pivot, but the GPU can instance them. | -| **Emission** | Enable this setting to make the emission color affect global illumination. | +| **Enable GPU Instancing** | Enable the checkbox to tell HDRP to render Meshes with the same geometry and Material in one batch when possible. This makes rendering faster. HDRP cannot render Meshes in one batch if they have different Materials, or if the hardware does not support GPU instancing. For example, you cannot [static-batch](https://docs.unity3d.com/Manual/DrawCallBatching.html) GameObjects that have an animation based on the object pivot, but the GPU can instance them. | +| **Emission** | Toggles whether emission affects global illumination. | | **- Global Illumination** | Use the drop-down to choose how color emission interacts with global illumination.
• **Realtime**: Select this option to make emission affect the result of real-time global illumination.
• **Baked**: Select this option to make emission only affect global illumination during the baking process.
• **None**: Select this option to make emission not affect global illumination. | -| **Motion Vector For Vertex Animation** | Enable this setting to make HDRP write motion vectors for GameObjects that use vertex animation. This removes the ghosting that vertex animation can cause. | \ No newline at end of file +| **Motion Vector For Vertex Animation** | Enable the checkbox to make HDRP write motion vectors for GameObjects that use vertex animation. This removes the ghosting that vertex animation can cause. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Lit.md b/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Lit.md index 86e814c1e11..c302cfd3833 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Lit.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Lit.md @@ -61,7 +61,7 @@ The following table describes the input ports on a Lit master node, including th ### Master node settings menu -To view these properties, click the cog icon in the top right of the master node. +To view these properties, click the gear icon in the top right of the master node. | **Property** | **Description** | | ------------------------------------ | ------------------------------------------------------------ | @@ -106,6 +106,6 @@ These properties are in the **Exposed Properties** section of the Inspector and | **Property** | **Description** | | -------------------------------------- | ------------------------------------------------------------ | -| **Enable GPU Instancing** | Enable this setting to tell HDRP to render Meshes with the same geometry and Material in one batch when possible. This makes rendering faster. HDRP cannot render Meshes in one batch if they have different Materials, or if the hardware does not support GPU instancing. For example, you can not [static-batch](https://docs.unity3d.com/Manual/DrawCallBatching.html) GameObjects that have an animation based on the object pivot, but the GPU can instance them. | +| **Enable GPU Instancing** | Enable the checkbox to tell HDRP to render Meshes with the same geometry and Material in one batch when possible. This makes rendering faster. HDRP cannot render Meshes in one batch if they have different Materials, or if the hardware does not support GPU instancing. For example, you cannot [static-batch](https://docs.unity3d.com/Manual/DrawCallBatching.html) GameObjects that have an animation based on the object pivot, but the GPU can instance them. | | **Emission** | Defines the Material's emission color value. Expects positive values. | -| **Motion Vector For Vertex Animation** | Indicates whether HDRP should evaluate motion vectors for animation. | \ No newline at end of file +| **Motion Vector For Vertex Animation** | Enable the checkbox to make HDRP write motion vectors for GameObjects that use vertex animation. This removes the ghosting that vertex animation can cause. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Unlit.md b/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Unlit.md index a0b0ce91a5f..6fbb00bb743 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Unlit.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Unlit.md @@ -66,5 +66,5 @@ These properties are in the **Exposed Properties** section of the Inspector and | **Property** | **Description** | | -------------------------------------- | ------------------------------------------------------------ | -| **Enable GPU Instancing** | Enable this setting to tell HDRP to render Meshes with the same geometry and Material in one batch when possible. This makes rendering faster. HDRP cannot render Meshes in one batch if they have different Materials, or if the hardware does not support GPU instancing. For example, you cannot [static-batch](https://docs.unity3d.com/Manual/DrawCallBatching.html) GameObjects that have an animation based on the object pivot, but the GPU can instance them. | -| **Double Sided Global Illumination** | When enabled, the lightmapper accounts for both sides of the geometry when calculating Global Illumination. Backfaces are not rendered or added to lightmaps, but get treated as valid when seen from other objects. When using the Porgressive Lightmapper backfaces bounce light using the same emission and albedo as frontfaces. | +| **Enable GPU Instancing** | Enable the checkbox to tell HDRP to render Meshes with the same geometry and Material in one batch when possible. This makes rendering faster. HDRP cannot render Meshes in one batch if they have different Materials, or if the hardware does not support GPU instancing. For example, you cannot [static-batch](https://docs.unity3d.com/Manual/DrawCallBatching.html) GameObjects that have an animation based on the object pivot, but the GPU can instance them. | +| **Double Sided Global Illumination** | When enabled, the lightmapper accounts for both sides of the geometry when calculating Global Illumination. Backfaces are not rendered or added to lightmaps, but get treated as valid when seen from other objects. When using the Progressive Lightmapper, backfaces bounce light using the same emission and albedo as frontfaces. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Menu-Items.md b/com.unity.render-pipelines.high-definition/Documentation~/Menu-Items.md new file mode 100644 index 00000000000..f6d6bebf80c --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/Menu-Items.md @@ -0,0 +1,40 @@ +# Menu items + +The High Definition Render Pipeline (HDRP) adds menu items to the Unity menu bar. This page shows where each menu item is and describes how each works. + +## Edit + +This section includes all the menu items under the **Edit** menu fold-out. To access them, go to **Edit > Render Pipeline > HD Render Pipeline**. + +### Upgrade From Previous Versions + +This group of menu items is useful when you upgrade HDRP to a later version. + +| **Item** | **Description** | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| **Upgrade HDRP Materials to Latest Version** | Upgrades all HDRP Materials in the project to the latest version. This is useful if HDRP's automatic Material upgrade process fails to upgrade a Material. | +| **Add Decal Layer Default to Loaded Mesh Renderers and Terrains** | Adds the **Decal Layer Default** item to every Mesh Renderer and Terrain in the currently open scene. This is useful when upgrading your HDRP project from Unity 2020.1 to 2020.2, if you want to use [Decal Layers](Decal.md#decal-layers). | +| **Add Decal Layer Default to Selected Mesh Renderers and Terrains** | Adds the **Decal Layer Default** item to every selected Mesh Renderer and Terrain in the currently open scene. This is useful when upgrading your HDRP project from Unity 2020.1 to 2020.2, if you want to use [Decal Layers](Decal.md#decal-layers). | +| **Fix Warning 'referenced script in (Game Object 'SceneIDMap') is missing' in loaded scenes** | Fixes an issue that occurs if you enter Play Mode with Reflection Probes that Unity baked prior to 2019.3. This is useful when upgrading your HDRP project from Unity 2019.2 to 2019.3. | + + + +### Upgrade From Built-in pipeline + +This group of menu items is useful when you upgrade your Unity Project from using the Built-in Render Pipeline to HDRP. + +| **Item** | **Description** | +| ----------------------------------------------------------- | ------------------------------------------------------------ | +| **Upgrade Project Materials to High Definition Materials** | Converts every compatible Material in your project to an HDRP Material. | +| **Upgrade Selected Materials to High Definition Materials** | Converts every compatible Material currently selected in the project window to an HDRP Material. | +| **Upgrade Scene Terrains to High Definition Terrains** | Replaces the built-in default standard terrain Material in every [Terrain](https://docs.unity3d.com/Manual/script-Terrain.html) in the scene with the HDRP default Terrain Material. | + + + +### Other items + +| **Item** | **Description** | +| --------------------------------------- | ------------------------------------------------------------ | +| **Render Selected Camera to Log EXR** | Exports the current [Camera](HDRP-Camera.md)'s view to a log-encoded EXR file. This is useful when [authoring lookup textures](Authoring-LUTs.md). | +| **Export Sky to Image** | Exports the current sky as a static HDRI. | +| **Check Scene Content for Ray Tracing** | Checks every GameObject in the current scene and throws warnings if:A Mesh Filter references a null Mesh.A Mesh Renderer references a null Material.A Submesh within a single Renderer reference both a transparent and opaque Material. | \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/More-Options.md b/com.unity.render-pipelines.high-definition/Documentation~/More-Options.md index a9dcc791cf7..ccf1936e018 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/More-Options.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/More-Options.md @@ -1,13 +1,13 @@ # More Options -The High Definition Render Pipeline (HDRP) components expose standard properties by default that are suitable for most use-cases. To fine-tune the behavior of your components, you can manually expose **more options** . +The High Definition Render Pipeline (HDRP) components expose standard properties by default that are suitable for most use-cases. However, some HDRP components include **more options** which you can use to fine-tune the behavior of the component. ## Exposing more options -Components that include more options have a cog icon to the right of each property section header. Click this cog icon to expose more options for that property section. For example, the [Light component’s](Light-Component.html) **General** section includes more options: +Not every component includes more options. If one does, it has a gear icon to the right of each property section header that includes more options. Click this gear icon to expose more options for that property section. For example, the [Light component’s](Light-Component.md) **General** section includes more options: ![](Images/MoreOptions1.png) -When you click the plus icon, Unity exposes more options for the **General** section. In this example, the **Light Layer** property appears: +When you click the gear icon, Unity exposes more options for the **General** section. In this example, the **Light Layer** property appears: ![](Images/MoreOptions2.png) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Ambient-Occlusion.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Ambient-Occlusion.md index 0142cd26699..a1d451e376f 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Ambient-Occlusion.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Ambient-Occlusion.md @@ -16,6 +16,8 @@ For information on how to use a Texture to specify ambient occlusion caused by d ![](Images/OverrideAmbientOcclusion1.png) +[!include[](snippets/Volume-Override-Enable-Properties.md)] + | **Property** | **Description** | | ---------------------------- | ------------------------------------------------------------ | | **Intensity** | Use the slider to guide the intensity of the ambient occlusion. Higher values lead to darker results. HDRP uses this value as an exponent to evaluate a pixel's final value for ambient occlusion. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Contact-Shadows.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Contact-Shadows.md index 00de0cfcf4f..cb951a4e7ca 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Contact-Shadows.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Contact-Shadows.md @@ -1,11 +1,18 @@ # Contact Shadows The Contact Shadows [Volume Override](Volume-Components.html) specifies properties which control the behavior of Contacts Shadows. Contact Shadows are shadows that The High Definition Render Pipeline (HDRP) [ray marches](Glossary.html#RayMarching) in screen space inside the depth buffer. The goal of using Contact Shadows is to capture small details that regular shadow mapping algorithms fail to capture. -## Using Contact Shadows -To use Contact Shadows in your Scene, you must first enable them for your Cameras. In the Inspector for your HDRP Asset, go to the **Default Frame Settings > Lighting** section and enable the **Contact Shadows** checkbox. All Cameras can now render Contact Shadows unless you override a Camera’s individual [Frame Settings](Frame-Settings.html). +## Enabling Contact Shadows +[!include[](snippets/Volume-Override-Enable.md)] + +For this feature: +The property to enable in your HDRP Asset is: **Lighting > Shadows > Use Contact Shadows**. +The property to enable in your Frame Settings is: **Lighting > Contact Shadows**. + -**Contact Shadows** use the [Volume](Volumes.html) framework, so to enable and modify **Contact Shadow** properties, you must add a **Contact Shadows** override to a [Volume](Volumes.html) in your Scene. To add **Contact Shadows** to a Volume: +## Using Contact Shadows + +**Contact Shadows** use the [Volume](Volumes.md) framework, so to enable and modify **Contact Shadow** properties, you must add a **Contact Shadows** override to a [Volume](Volumes.md) in your Scene. To add **Contact Shadows** to a Volume: 1. In the Scene or Hierarchy view, select a GameObject that contains a Volume component to view it in the Inspector. 2. In the Inspector, navigate to **Add Override > Shadowing** and click on **Contact Shadows**. HDRP now applies **Contact Shadows** to any Camera this Volume affects. @@ -20,6 +27,8 @@ Only one Light can cast Contact Shadows at a time. This means that, if you have ![](Images/Override-ContactShadows1.png) +[!include[](snippets/Volume-Override-Enable-Properties.md)] + | Property | Description | | :------------------------ | :----------------------------------------------------------- | | __Enable__ | Enable the checkbox to make HDRP process Contact Shadows for this [Volume](Volumes.html). | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Diffusion-Profile.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Diffusion-Profile.md index 23aff332e11..d61bf26f804 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Diffusion-Profile.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Diffusion-Profile.md @@ -13,6 +13,8 @@ To add a **Diffusion Profile Override** to a Volume: ![](Images\Override-DiffusionProfile1.png) +[!include[](snippets/Volume-Override-Enable-Properties.md)] + | **Property** | **Description** | | ------------------------------------------ | ------------------------------------------------------------ | | **Diffusion Profile List** | Assign a Diffusion Profile to each field to create a list of Diffusion Profiles that Materials in this Volume can use. Click the plus icon to add another field. To remove a Diffusion Profile from the list, select it in the list and click the minus icon. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Exposure.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Exposure.md index 18b7f293bef..91fa062152c 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Exposure.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Exposure.md @@ -13,6 +13,8 @@ To work with physically-based lighting and Materials, you need to set up the Sce ![](Images/Override-Exposure1.png) +[!include[](snippets/Volume-Override-Enable-Properties.md)] + | **Property** | **Description** | | ------------ | ------------------------------------------------------------ | | **Mode** | Use the drop-down to select the method that HDRP uses to process exposure:
• [**Fixed**](#FixedProperties): Allows you to manually sets the Scene exposure.
• [**Automatic**](#AutomaticProperties): Automatically sets the exposure depending on what is on screen.
• [**Curve Mapping**](#CurveMappingProperties): Maps the current Scene exposure to a custom curve.
• [**Use Physical Camera**](#UsePhysicalCameraProperties): Uses the current physical Camera settings to set the Scene exposure. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Fog.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Fog.md index 837cd35aa0b..4fed2d5e79b 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Fog.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Fog.md @@ -35,6 +35,8 @@ The **Fog** override of the active Volume controls the appearance of the global ![](Images/Override-VolumetricFog1.png) +[!include[](snippets/Volume-Override-Enable-Properties.md)] + | Property | Function | | :----------------------- | :----------------------------------------------------------- | | **Enable** | Enables the fog. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Gradient-Sky.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Gradient-Sky.md index 37cbf63c701..62d0b507473 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Gradient-Sky.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Gradient-Sky.md @@ -17,6 +17,8 @@ After you add a **Gradient Sky** override, you must set the Volume to use **Grad ![](Images/Override-GradientSky1.png) +[!include[](snippets/Volume-Override-Enable-Properties.md)] + | Property | Description | | ---------------------- | ------------------------------------------------------------ | | **Top** | Use the color picker to select the color of the upper hemisphere of the sky. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-HDRI-Sky.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-HDRI-Sky.md index 04fd3300767..acd9fb468b8 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-HDRI-Sky.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-HDRI-Sky.md @@ -19,6 +19,8 @@ After you add an **HDRI Sky** override, you must set the Volume to use **HDRI Sk ![](Images/Override-HDRISky1.png) +[!include[](snippets/Volume-Override-Enable-Properties.md)] + | Property | Description | | -------------------------------- | ------------------------------------------------------------ | | **HDRI Sky** | Assign a HDRI Texture that HDRP uses to render the sky. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md index 0688b528c12..29f4f73ec06 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Indirect-Lighting-Controller.md @@ -15,6 +15,8 @@ The **Indirect Lighting Controller** uses the [Volume](Volumes.html) framework, ![](Images/Override-IndirectLightingController1.png) +[!include[](snippets/Volume-Override-Enable-Properties.md)] + | Property | Description | | ------------------------------- | ------------------------------------------------------------ | | **Indirect Diffuse Lighting Multiplier** | A multiplier for lightmaps, Light Probes, Light Probe Volumes, Screen-Space Global Illumination, and [Ray-Traced Global Illumination](Ray-Traced-Global-Illumination.md). HDRP multiplies the light data from all of these by this value. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Micro-Shadows.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Micro-Shadows.md index 667953256f6..317b5a594a2 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Micro-Shadows.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Micro-Shadows.md @@ -16,10 +16,14 @@ HDRP uses the [Volume](Volumes.html) framework to generate **Micro Shadows**, so 2. In the Inspector, navigate to **Add Override > Shadowing** and click on **Micro Shadows**. HDRP now processes **Micro Shadows** for any Camera this Volume affects. +Micro shadowing only works with directional [Lights](Light-Component.md). If you enable micro shadows, make sure you have a directional Light in the Scene. + ## Properties ![](Images/OverrideMicroShadows2.png) +[!include[](snippets/Volume-Override-Enable-Properties.md)] + | **Property** | **Description** | | ------------ | ------------------------------------------------------------ | | **Enable** | Enable the checkbox to make HDRP calculate micro shadows when this Volume affects the Camera. | @@ -27,10 +31,10 @@ HDRP uses the [Volume](Volumes.html) framework to generate **Micro Shadows**, so ## Details -Micro shadowing gives the impression of extremely detailed lighting that can capture small details. it relies on how you generate your Textures. When authoring the normal map and ambient occlusion map of the Material, consider the following: +Micro shadowing gives the impression of extremely detailed lighting that can capture small details. It relies on how you generate your Textures so, to produce better results, consider the following when you author the normal map and ambient occlusion map for a Material: -- For better results, capture the details of both Textures in a consistent way. -- Always use the same pipeline to produce your ambient occlusion maps. +- Make sure to capture the details of both Textures in a consistent way. +- Always use the same pipeline to produce your normal maps and ambient occlusion maps. Note that processing micro shadows is more resource intensive than not processing them. diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Physically-Based-Sky.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Physically-Based-Sky.md index 9432fb876fd..d5a4d5ea6e8 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Physically-Based-Sky.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Physically-Based-Sky.md @@ -31,6 +31,8 @@ To change how much the atmosphere attenuates light, you can change the density o ## Properties +[!include[](snippets/Volume-Override-Enable-Properties.md)] + ### Planet | **Property** | **Description** | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Procedural-Sky.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Procedural-Sky.md index c78df7556c3..1724440cc9f 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Procedural-Sky.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Procedural-Sky.md @@ -6,19 +6,21 @@ This sky is similar to the procedural sky in Unity’s built-in render pipeline. ## Deprecation -HDRP deprecated **Procedural Sky** in 2019.3 and replaced it with [Physically Based Sky](Override-Physically-Based-Sky.html). To use Procedural Sky for HDRP Projects in Unity 2019.3 or later, follow the instructions on the [Upgrading from 2019.2 to 2019.3 guide](Upgrading-From-2019.2-to-2019.3.html#ProceduralSky). +HDRP deprecated **Procedural Sky** in 2019.3 and replaced it with [Physically Based Sky](Override-Physically-Based-Sky.md). To use Procedural Sky for HDRP Projects in Unity 2019.3 or later, follow the instructions on the [Upgrading from 2019.2 to 2019.3 guide](Upgrading-from-2019.2-to-2019.3.md#ProceduralSky). ## Using Procedural Sky -**Procedural Sky** uses the [Volume](Volumes.html) framework, so to enable and modify **Procedural Sky** properties, you must add a **Procedural Sky** override to a [Volume](Volumes.html) in your Scene. To add **Procedural Sky** to a Volume: +**Procedural Sky** uses the [Volume](Volumes.md) framework, so to enable and modify **Procedural Sky** properties, you must add a **Procedural Sky** override to a [Volume](Volumes.md) in your Scene. To add **Procedural Sky** to a Volume: 1. In the Scene or Hierarchy view, select a GameObject that contains a Volume component to view it in the Inspector. 2. In the Inspector, navigate to **Add Override > Sky** and click on **Procedural Sky**. -After you add a **Procedural Sky** override, you must set the Volume to use **Procedural Sky**. The [Visual Environment](Override-Visual-Environment.html) override controls which type of sky the Volume uses. In the **Visual Environment** override, navigate to the **Sky** section and set the **Type** to **Procedural Sky**. HDRP now renders a **Procedural Sky** for any Camera this Volume affects. +After you add a **Procedural Sky** override, you must set the Volume to use **Procedural Sky**. The [Visual Environment](Override-Visual-Environment.md) override controls which type of sky the Volume uses. In the **Visual Environment** override, navigate to the **Sky** section and set the **Type** to **Procedural Sky**. HDRP now renders a **Procedural Sky** for any Camera this Volume affects. ## Properties +[!include[](snippets/Volume-Override-Enable-Properties.md)] + | Property | Description | | ------------------------- | ------------------------------------------------------------ | | **Enable Sun Disk** | Enable the checkbox to make HDRP display the sun disk defined by the **Sky Size**, **Sun Size Convergence**, **Exposure**, and **Multiplier** . | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Screen-Space-Reflection.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Screen-Space-Reflection.md index 1e643b07de9..dcba2e1b61b 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Screen-Space-Reflection.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Screen-Space-Reflection.md @@ -2,9 +2,15 @@ The **Screen Space Reflection** (SSR) override is a High Definition Render Pipeline (HDRP) feature that uses the depth and color buffer of the screen to calculate reflections. For information about how SSR works in HDRP, see the [reflection documentation](Reflection-in-HDRP.md#ScreenSpaceReflection). -## Using Screen Space Reflection +## Enabling Screen Space Reflection + +[!include[](snippets/Volume-Override-Enable.md)] -To use SSR in your Scene, you must enable it for your Cameras. In the Inspector for your [HDRP Asset](HDRP-Asset.md), go to the **Default Frame Settings > Lighting > Reflections** section and enable the **Screen Space Reflection** checkbox. +For this feature: +The property to enable in your HDRP Asset is: **Lighting > Reflections > Screen Space Reflection**. +The property to enable in your Frame Settings is: **Lighting > Screen Space Reflection**. + +## Using Screen Space Reflection HDRP uses the [Volume](Volumes.md) framework to calculate SSR, so to enable and modify SSR properties, you must add a **Screen Space Reflection** override to a [Volume](Volumes.md) in your Scene. To add **Screen Space Reflection** to a Volume: @@ -16,6 +22,8 @@ HDRP uses the [Volume](Volumes.md) framework to calculate SSR, so to enable and ![](Images/Override-ScreenSpaceReflection1.png) +[!include[](snippets/Volume-Override-Enable-Properties.md)] + | **Property** | **Description** | | ----------------------------- | ------------------------------------------------------------ | | **Screen Edge Fade Distance** | Use the slider to control the distance at which HDRP fades out screen space reflections when the destination of the ray is near the boundaries of the screen. Increase this value to increase the distance from the screen edge at which HDRP fades out screen space reflections for a ray destination. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Screen-Space-Refraction.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Screen-Space-Refraction.md index 5878745b7d5..da54e32b984 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Screen-Space-Refraction.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Screen-Space-Refraction.md @@ -14,6 +14,8 @@ HDRP uses the [Volume](Volumes.html) framework to calculate SSR, so to enable an ![](Images/Override-ScreenSpaceRefraction1.png) +[!include[](snippets/Volume-Override-Enable-Properties.md)] + | **Property** | **Description** | | ----------------------------- | ------------------------------------------------------------ | | **Screen Edge Fade Distance** | Use the slider to control the distance at which HDRP fades out the refraction effect when the destination of the ray is near the boundaries of the screen. Increase this value to increase the distance from the screen edge at which HDRP fades out the refraction effect for a ray destination. | \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Shadows.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Shadows.md index 2b678c322f0..8f8ca0ae5da 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Shadows.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Shadows.md @@ -15,6 +15,8 @@ The **Shadows** override comes as default when you create a **Scene Settings** G ![](Images/Override-Shadows1.png) +[!include[](snippets/Volume-Override-Enable-Properties.md)] + | **Property** | **Description** | | ---------------- | ------------------------------------------------------------ | | **Working Unit** | Use the drop-down to select the unit that you want to use to define the cascade splits.
• **Metric**: Defines cascade splits and borders in meters.
• **Percent**: Defines cascade splits and borders as a percentage of **Max Distance**. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-Visual-Environment.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-Visual-Environment.md index ab447d7b676..1a1095cd32c 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-Visual-Environment.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-Visual-Environment.md @@ -15,6 +15,8 @@ The **Visual Environment** override comes as default when you create a **Scene S ![](Images/Override-VisualEnvironment1.png) +[!include[](snippets/Volume-Override-Enable-Properties.md)] + ### Sky | **Property** | **Description** | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Post-Processing-Propagating-NaNs.md b/com.unity.render-pipelines.high-definition/Documentation~/Post-Processing-Propagating-NaNs.md new file mode 100644 index 00000000000..30a52dba5e1 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/Post-Processing-Propagating-NaNs.md @@ -0,0 +1,57 @@ +# **Post-processing: propagating Not a Number or Infinite values** + +Not a Number (NaN) and Infinite (Inf) values occur when shader operations produce an undefined result. Visually, they manifest as purely black or white pixels. + +Example operations that can lead to a NaN/Inf are: + +- Performing a square root (sqrt) or logarithm (log/log2) on any negative number produces a NaN. +- Performing a modulo operation, A % B, where A is infinite or B is 0 produces a NaN. +- Dividing any number by 0 produces an Inf (for example, normalizing a vector with a length of 0). + +Aside from shader operations, uninitialized memory can also contain/produce NaNs or Infs. On some platforms, the pixel values on newly created [Render Textures](https://docs.unity3d.com/Manual/class-RenderTexture.html) are not initialized with a value of 0. This means that if you access new Render Textures before writing to or clearing them, they might generate a NaN/Inf. As a general rule, you should always either clear your Render Textures before you use them, or write to every value you want to read from before you read from them. + +## Propagating NaNs/Infs + +Any operation that has a NaN or an Inf as an operand also produces a NaN/Inf as a result. This is important in the High Definition Render Pipeline (HDRP), because any filtering or blur HDRP performs that involves NaN/Inf values spreads the invalid values further. + +A commonly reported issue in HDRP is that [bloom](Post-Processing-Bloom.md) generates a black screen. The bloom effect does not produce NaNs/Infs itself, but it spreads a NaN/Inf generated elsewhere across the screen. This happens because to calculate bloom, HDRP downsamples/filters the scene color and then upsamples it back to the desired resolution. If there is a single NaN/Inf on the screen, the downsample process spreads the invalid value until it covers the whole texture, and the subsequent upsampling therefore contains only NaN values, which leads to the full screen being black. + +For example, see a NaN caused by a material issue that spreads to the whole scene when HDRP calculates bloom: + +![](Images/Post-processingPropagatingNaNsExample1.png) + +![](Images/Post-processingPropagatingNaNsExample2.png) + +![](Images/Post-processingPropagatingNaNsExample3.png) + +![](Images/Post-processingPropagatingNaNsExample4.png) + +A similar issue occurs when HDRP generates color pyramids for use by features such as [screen-space reflection](Override-Screen-Space-Reflection.md), [screen-space refraction](Override-Screen-Space-Refraction.md), and distortion. + +If you disable bloom and the screen stops being black, the cause of the black screen is likely because a single NaN/Inf pixel is present, but not really visible, and bloom propagated it across the whole screen. It is **not** because bloom created the invalid values. + +## Fixing NaNs and Infs + +The best way to stop bloom or other HDRP features from propagating NaN/Inf values is to fix the source of the NaN/Inf values. For information on how to do this, see [finding NaNs and Infs](#finding-nans-and-infs). + +If you are unable to fix the source of the NaN/Inf values, [HDRP Cameras](HDRP-Camera.md) include a feature which replaces NaN and Inf values with a black pixel. This stops effects like bloom from propagating NaN/Inf values, but is a fairly resource intensive process. To enable this feature, select a Camera and, in the Inspector, enable the **Stop NaNs** checkbox. Note that you should only enable this feature if you are unable to fix the root cause of the NaN/Inf values. + +### Finding NaNs and Infs + +To find the root cause of a NaN/Inf, HDRP includes a debug mode which displays pixels that contain NaNs/Infs in a recognizable color. To use this debug mode: + +1. Open the Render Pipelines Debug window (menu: **Window > Render Pipeline > Render Pipeline Debug**). +2. Go to **Rendering** and set **Fullscreen Debug Mode** to **NanTracker**. + +This helps you to see if there are actually NaNs/Infs on screen and which material causes them. However, if you need more information, such as which particular draw call causes the issue, you can use frame debugging tools such as [RenderDoc](https://renderdoc.org/). For information on how to use RenderDoc to capture frames in Unity, see [RenderDoc integration](https://docs.unity3d.com/Manual/RenderDocIntegration.html). + +#### RenderDoc + +After you capture a frame, RenderDoc can display pixels with a NaN/Inf value as pure red, which helps you to find NaN/Inf values because it is much easier to see than the standard white/black pixels that HDRP renders for invalid values. To do this, in the Texture Viewer, open the **Overlay** drop-down and click the **NaN/Inf/-ve Display** option. + +![](Images/Post-processingPropagatingNaNsRenderDoc.png) + + +Now that it is easier to see the NaN/Inf values, you can start to look for them. If they are still not obvious, you can look at the bloom dispatches to see where bloom propagates the NaN/Inf pixels from, then pinpoint the exact pixel/s responsible. Taking the example images in the [propagating NaNs/Infs section](#Propagating-NaNs/Infs), you can see by how bloom expands the NaN/Inf values that the source is around the center of the screen, on the sphere's Material. + +After you find which Materials/shaders produce the NaNs/Infs, you can then debug them to find out which operation actually causes the invalid values. \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Getting-Started.md b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Getting-Started.md index 1a7c0d7e3ce..487ab594107 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Getting-Started.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Getting-Started.md @@ -15,7 +15,7 @@ This document covers: ## Hardware requirements Full ray tracing hardware acceleration is available on following GPUs: -- NVIDIA GeForce RTX 2060, RTX 2080 Super, RTX 2070, RTX 2070 Super, RTX 2080, RTX 2080 Super, RTX 2080 Ti +- NVIDIA GeForce RTX 2060, RTX 2060 Super, RTX 2070, RTX 2070 Super, RTX 2080, RTX 2080 Super, RTX 2080 Ti, and NVIDIA TITAN RTX - NVIDIA Quadro RTX 3000 (laptop only), RTX 4000, RTX 5000, RTX 6000, RTX 8000 @@ -156,6 +156,15 @@ To enable ray tracing for a specific Camera: 2. In the **General** section, enable **Custom Frame Settings**. This exposes Frame Settings just for this Camera. 3. in the **Rendering** section, enable **Ray Tracing**. + + +#### Build settings + +To build your Project to a Unity Player, ray tracing requires that the build uses 64 bits architecture. To set your build to use 64 bits architecture: + +1. Open the Build Settings window (menu: **File > Build Settings**). +2. From the **Architecture** drop-down, select **x86_64**. + ## Ray tracing effects overview diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Recursive-Rendering.md b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Recursive-Rendering.md index 322b5682fe5..e2465df738b 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Recursive-Rendering.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Recursive-Rendering.md @@ -25,7 +25,7 @@ Now that you have recursive rendering set up in your Scene, you must set GameObj You can also do this for Shader Graph master nodes: 1. In the Project window, double-click on the Shader to open it in Shader Graph. -2. On the master node, click the cog, then select Raytracing from the Rendering Pass drop-down. +2. On the master node, click the gear, then select Raytracing from the Rendering Pass drop-down. ## Properties diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Shadows-in-HDRP.md b/com.unity.render-pipelines.high-definition/Documentation~/Shadows-in-HDRP.md index 2dede000014..2999e3aa2c1 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Shadows-in-HDRP.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Shadows-in-HDRP.md @@ -41,7 +41,7 @@ In HDRP, each individual Light component controls its own shadow biasing using t - **Slope-Scale Depth Bias** - **Normal Bias** -Find these settings under the **Shadows** section. If some of the property fields are missing, click the [more options](More-Options.html) cog to expose them. For details on how each property controls the shadow biasing, see the [Light documentation](Light-Component.html). +Find these settings under the **Shadows** section. If some of the property fields are missing, click the [more options](More-Options.md) gear to expose them. For details on how each property controls the shadow biasing, see the [Light documentation](Light-Component.md). ![](Images/Shadows1.png) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md b/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md index 2b69e9a4776..e715701e403 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md @@ -1,9 +1,9 @@ * [High Definition Render Pipeline](index) +* [Requirements](System-Requirements.md) * Features * [Features List](HDRP-Features) * [Comparison with the Built-in Render Pipeline](Feature-Comparison) * Getting started - * [System Requirements](System-Requirements.md) * [Getting Started with HDRP](Getting-started-with-HDRP) * [Upgrading to HDRP](Upgrading-To-HDRP) * [Render Pipeline Wizard](Render-Pipeline-Wizard) @@ -11,6 +11,7 @@ * [Exposing More Options](More-Options) * [Sample Content](HDRP-Sample-Content) * [Sample project](HDRP-Sample-Projects) + * [Menu Items](Menu-Items.md) * Upgrading HDRP between Unity Versions * [Material Upgrade](Material-Upgrade) * [2019.1 to 2019.2](Upgrading-from-2019.1-to-2019.2) @@ -39,6 +40,7 @@ * [Physically Based Sky](Override-Physically-Based-Sky) * [Procedural Sky](Override-Procedural-Sky) * [Visual Environment](Override-Visual-Environment) + * [Volumes API](Volumes-API.md) * Render Pipeline Settings * [HDRP Asset](HDRP-Asset) * [Frame Settings](Frame-Settings) @@ -59,6 +61,10 @@ * [Subsurface Scattering Materials](Subsurface-Scattering) * [Diffusion Profile](Diffusion-Profile) * Shader List + * Autodesk Interactive + * [Autodesk Interactive Shader](Autodesk-Interactive-Shader) + * [Autodesk Interactive Masked Shader](Autodesk-Interactive-Shader-Masked) + * [Autodesk Interactive Transparent Shader](Autodesk-Interactive-Shader-Transparent) * [AxF Shader](AxF-Shader) * [Decal Shader](Decal-Shader) * [Layered Lit Shader](Layered-Lit-Shader) @@ -127,6 +133,7 @@ * [Overview](Authoring-LUTs) * [Authoring in Adobe Photoshop](LUT-Authoring-Photoshop) * [Authoring in DaVinci Resolve](LUT-Authoring-Resolve) + * [Propagating NaNs](Post-Processing-Propagating-NaNs) * Ray Tracing * [Getting Started with Ray Tracing](Ray-Tracing-Getting-Started) * Effects and Volume Overrides diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Terrain-Lit-Shader.md b/com.unity.render-pipelines.high-definition/Documentation~/Terrain-Lit-Shader.md index a2e5d3ac8db..53bf70ae5b5 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Terrain-Lit-Shader.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Terrain-Lit-Shader.md @@ -17,7 +17,7 @@ To create a new Terrain Lit Shader Material: To use a Terrain Lit Material, you must assign it to a Terrain: -1. View the Terrain in the Inspector and click on the cog button to go to the **Terrain Settings** section. +1. View the Terrain in the Inspector and click on the gear button to go to the **Terrain Settings** section. 2. Either drag and drop or use the radio button to assign your Terrain Lit Material to the **Material** property. ![](Images/TerrainLitShader1.png) @@ -43,4 +43,4 @@ To use a Terrain Lit Material, you must assign it to a Terrain: | **Property** | **Description** | | ------------------------- | ------------------------------------------------------------ | -| **Enable GPU Instancing** | Enable this checkbox to tell HDRP to render meshes with the same geometry and Material/Shader in one batch when possible. This makes rendering faster. HDRP can not render Meshes in one batch if they have different Materials, or if the hardware does not support GPU instancing. | \ No newline at end of file +| **Enable GPU Instancing** | Enable the checkbox to tell HDRP to render Meshes with the same geometry and Material in one batch when possible. This makes rendering faster. HDRP cannot render Meshes in one batch if they have different Materials, or if the hardware does not support GPU instancing. For example, you cannot [static-batch](https://docs.unity3d.com/Manual/DrawCallBatching.html) GameObjects that have an animation based on the object pivot, but the GPU can instance them. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Unlit-Shader.md b/com.unity.render-pipelines.high-definition/Documentation~/Unlit-Shader.md index 875abfc1a44..58c4e9f2b3f 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Unlit-Shader.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Unlit-Shader.md @@ -48,8 +48,8 @@ Surface options control the overall look of your Material's surface and how Unit | **- Offset** | Set an **X** and **Y** offset for the **Emissive Color** UV. HDRP uses the **X** and **Y** values to offset the Texture assigned to the **Emissive Color** across the Material’s surface, in object space. | | **Emission Intensity** | Set the overall strength of the emission effect for this Material.
Use the drop-down to select one of the following [physical light units](Physical-Light-Units.html) to use for intensity:
• [Luminance](Physical-Light-Units.html#Luminance)
• [EV100](Physical-Light-Units.html#EV) | | **Exposure Weight** | Use the slider to set how much effect the exposure has on the emission power. For example, if you create a neon tube, you would want to apply the emissive glow effect at every exposure. | -| **Emission** | Enable the checkbox to make the emission color affect global illumination. | -| **- Global Illumination** | Use the drop-down to choose how color emission interacts with global illumination.
• **Realtime**: Select this option to make emission affect the result of real-time global illumination.
• **Baked**: Select this option to make emission only affect global illumination during the baking process.
• **None**: Select this option to make emission not affect global illumination. | +| **Emission** | Toggles whether emission affects global illumination. | +| **- Global Illumination** | The mode HDRP uses to determine how color emission interacts with global illumination.
• **Realtime**: Select this option to make emission affect the result of real-time global illumination.
• **Baked**: Select this option to make emission only affect global illumination during the baking process.
• **None**: Select this option to make emission not affect global illumination. | ### Transparency Inputs @@ -59,5 +59,5 @@ Unity exposes this section if you select **Transparent** from the **Surface Type | Property| Description | |:---|:---| -| **Enable GPU instancing** | Enable the checkbox to tell HDRP to render Meshes with the same geometry and Material in one batch when possible. This makes rendering faster. HDRP cannot render Meshes in one batch if they have different Materials, or if the hardware does not support GPU instancing. For example, you can not [static-batch](https://docs.unity3d.com/Manual/DrawCallBatching.html) GameObjects that have an animation based on the object pivot, but the GPU can instance them. | +| **Enable GPU instancing** | Enable the checkbox to tell HDRP to render Meshes with the same geometry and Material in one batch when possible. This makes rendering faster. HDRP cannot render Meshes in one batch if they have different Materials, or if the hardware does not support GPU instancing. For example, you cannot [static-batch](https://docs.unity3d.com/Manual/DrawCallBatching.html) GameObjects that have an animation based on the object pivot, but the GPU can instance them. | | **Add Precomputed Velocity** | Enable the checkbox to use precomputed velocity information stored in an Alembic file. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-To-HDRP.md b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-To-HDRP.md index f9c4e6764a8..ff980c69f3a 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-To-HDRP.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-To-HDRP.md @@ -59,7 +59,11 @@ You can find these options in either: * The Render Pipeline Wizard window, inside the **Project Migration Quick-links** section. -This process can not automatically upgrade custom Materials or Shaders to HDRP. You must [convert custom Materials and Shaders manually](#ManualConversion). +This process cannot automatically upgrade custom Materials or Shaders to HDRP. You must [convert custom Materials and Shaders manually](#ManualConversion). This process also cannot upgrade particle shaders. Even though HDRP does not support particle shaders, it does provide some 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: + +1. Open the Package Manager window (menu: **Window > Package Manager**). +2. Find and click the **High Definition RP** entry. +3. In the package information for **High Definition RP**, go to the **Samples** section and click the **Import into Project** button next to **Particle System Shader Samples**. @@ -101,7 +105,7 @@ To set up lighting in your HDRP Project: 2. Create a new Volume Profile for this Volume. To do this, open the Inspector for the Volume and click the **New** button. 3. Add a **Shadows** override (**Add Override > Shadowing > Shadows**), then enable **Max Distance** and set it to **50**. -4. On the Light that represents the Sun (which is the Light component on the **Directional Light** GameObject), set the **Intensity** to **100000** and the **Color** to white. Then, to see the sun in the sky, go to the **General** panel, enable [More Options](More-Options.html), and set the **Angular Diameter** to **3**. +4. On the Light that represents the Sun (which is the Light component on the **Directional Light** GameObject), set the **Intensity** to **100000** and the **Color** to white. Then, to see the sun in the sky, go to the **Shape** section and set the **Angular Diameter** to **3**. 5. The Scene is now over-exposed. To fix this, select the **Global Settings** GameObject you created in step **3a** and add an **Exposure** override to its Volume component (**Add Override > Exposure**). Then, set the **Mode** to **Automatic**. 6. To refresh the exposure, go to the Scene view and enable **Animate Materials**. ![](Images/UpgradingToHDRP2.png) @@ -116,7 +120,7 @@ To set up lighting in your HDRP Project: 2. Change the **Intensity** to **17000** **Lumen**. This is to represent two 8500 Lumen light bulbs. - 3. In the **Emission** section, enable [More Options](More-Options.html). + 3. In the **Emission** section, enable [More Options](More-Options.md). 4. Enable the **Reflector** checkbox. This simulates a reflective surface behind the spot Light to adjust the visual intensity. 9. Make the light bulb Material emissive: diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Volumes.md b/com.unity.render-pipelines.high-definition/Documentation~/Volumes.md index 9314ccccb48..27f64ddfd51 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Volumes.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Volumes.md @@ -10,6 +10,8 @@ At runtime, HDRP looks at all of the enabled Volumes attached to active GameObje Volumes can contain different combinations of Volume overrides. For example, one Volume may hold a Physically Based Sky Volume override while other Volumes hold an Exponential Fog Volume override. +Note that, for Volumes with the same priority, there is no guarantee on the order in which HDRP evaluates them. This means that, depending on creation order, a global Volume can take precedence over a local Volume. The result is that a Camera can go within the bounds of a local Volume but still exclusively use the Volume Override properties from a global Volume in the Scene. + ## Properties ![image alt text](Images/Volumes1.png) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/Volume-Override-Enable-Override.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/Volume-Override-Enable-Override.md new file mode 100644 index 00000000000..62f901213f2 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/Volume-Override-Enable-Override.md @@ -0,0 +1 @@ +To use this feature in your Scene, you must first enable it for your project and then enable it for your Cameras. To enable features in your project, you use the [HDRP Asset](../HDRP-Asset.md) and to enable features for your Cameras, you use [Frame Settings](../Frame-Settings.md). You can enable features either for all Cameras, using the Default Frame Settings, or for specific Cameras, by overriding each Camera's individual Frame Settings. \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/Volume-Override-Enable-Properties.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/Volume-Override-Enable-Properties.md new file mode 100644 index 00000000000..d5304c30a24 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/Volume-Override-Enable-Properties.md @@ -0,0 +1 @@ +To edit properties in any Volume component override, enable the checkbox to the left of the property. This also tells HDRP to use the property value you specify for the Volume component rather than the default value. If you disable the checkbox, HDRP ignores the property you set and uses the Volume’s default value for that property instead. \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/ao-map.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/ao-map.md new file mode 100644 index 00000000000..aefb10c2a5a --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/ao-map.md @@ -0,0 +1,4 @@ + +**AoMap** +The texture that defines the occlusion map to simulate shadowing of ambient light. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/base-color.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/base-color.md new file mode 100644 index 00000000000..75a08793a9a --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/base-color.md @@ -0,0 +1,4 @@ + +**BaseColor** +The color of the material. This property is similar to the albedo color available in the Physically Based shader.
If you enable **UseColorMap**, HDRP ignores this property. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/color-map.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/color-map.md new file mode 100644 index 00000000000..daff1f5a88b --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/color-map.md @@ -0,0 +1,4 @@ + +**ColorMap** +The texture to use to color the material. This property is similar to the albedo color available in the Physically Based shader.
If you disable **UseColorMap**, HDRP ignores this property. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/emissive-map.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/emissive-map.md new file mode 100644 index 00000000000..8fe06c73013 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/emissive-map.md @@ -0,0 +1,4 @@ + +**EmissiveMap** +The texture that defines the emissive color of the surface.
If you disable **UseEmissiveMap**, HDRP ignores this property. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/emissive.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/emissive.md new file mode 100644 index 00000000000..31dde48dddd --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/emissive.md @@ -0,0 +1,4 @@ + +**Emissive** +The color of the light the surface emits.
If you enable **UseEmissiveMap**, HDRP ignores this property. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/mask-map.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/mask-map.md new file mode 100644 index 00000000000..62afea0de0f --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/mask-map.md @@ -0,0 +1,4 @@ + +**MaskMap** +The texture that defines the opacity mask of the surface.
Note that HDRP only uses the red channel of this texture as the opacity mask. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/mask-threshold.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/mask-threshold.md new file mode 100644 index 00000000000..9663a847c05 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/mask-threshold.md @@ -0,0 +1,4 @@ + +**MaskThreshold** +The opacity threshold HDRP uses to to determine which areas of the **MaskMap** render as transparent or completely opaque. For example, for a **MaskThreshold** value of 0.5, a pixel in the **MaskMap** with a value of 0.6 appears completely opaque and a pixel with a value of 0.4 appears completely transparent. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/metallic-map.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/metallic-map.md new file mode 100644 index 00000000000..50c97c0eef6 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/metallic-map.md @@ -0,0 +1,4 @@ + +**MetallicMap** +The texture that defines the metallic value of the surface.
If you disable **UseMetallicMap**, HDRP ignores this property.
Note that HDRP only uses the red channel of this texture to determine the metallic value of the material's surface. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/metallic.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/metallic.md new file mode 100644 index 00000000000..013e1174502 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/metallic.md @@ -0,0 +1,4 @@ + +**Metallic** +Determines how metal-like the surface is.
If you enable **UseMetallicMap**, HDRP ignores this property. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/normal-map.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/normal-map.md new file mode 100644 index 00000000000..5571b242a10 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/normal-map.md @@ -0,0 +1,4 @@ + +**NormalMap** +The texture that defines the [normal map](https://docs.unity3d.com/Manual/StandardShaderMaterialParameterNormalMap.html) for this material, in tangent space. This is similar to the one in the [Standard Shader](https://docs.unity3d.com/Manual/shader-StandardShader.html) in the Built-in Render Pipeline.
If you disable **UseNormalMap**, HDRP ignores this property. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/opacity.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/opacity.md new file mode 100644 index 00000000000..722c2f795e6 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/opacity.md @@ -0,0 +1,4 @@ + +**Opacity** +The opacity of the surface.
If you enable **UseOpacityMap**, HDRP ignores this property. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/roughness-map.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/roughness-map.md new file mode 100644 index 00000000000..a66ba3eddd5 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/roughness-map.md @@ -0,0 +1,4 @@ + +**RoughnessMap** +The texture that defines the roughness value of the surface. Note that only the Red channel is taken into account.
If you disable **UseRoughnessMap**, HDRP ignores this property.
Note that HDRP only uses the red channel of this texture to determine the roughness value of the material's surface. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/roughness.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/roughness.md new file mode 100644 index 00000000000..82925d9586c --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/roughness.md @@ -0,0 +1,4 @@ + +**Roughness** +The roughness of the surface.
If you enable **UseRoughnessMap**, HDRP ignores this property. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-ao-map.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-ao-map.md new file mode 100644 index 00000000000..f00d282e807 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-ao-map.md @@ -0,0 +1,4 @@ + +**UseAoMap** +Toggles whether the material uses the **AoMap** property. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-color-map.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-color-map.md new file mode 100644 index 00000000000..68d2995f26e --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-color-map.md @@ -0,0 +1,4 @@ + +**UseColorMap** +Toggles whether the material uses the **ColorMap** property or the **BaseColor** property to color its surface. Enable this checkbox to use the **ColorMap** property, disable this checkbox to use the **BaseColor** property. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-emissive-map.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-emissive-map.md new file mode 100644 index 00000000000..768b1ffc4f2 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-emissive-map.md @@ -0,0 +1,4 @@ + +**UseEmissiveMap** +Toggles whether the material uses the **EmissiveMap** property or the **Emissive** property to set the emissive color of its surface. Enable this checkbox to use the **EmissiveMap** property, disable this checkbox to use the **Emissive** property. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-metallic-map.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-metallic-map.md new file mode 100644 index 00000000000..91bb10abea3 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-metallic-map.md @@ -0,0 +1,4 @@ + +**UseMetallicMap** +Toggles whether the material uses the **MetallicMap** property or the **Metallic** property to specify the metallic value of its surface. Enable this checkbox to use the **MetallicMap** property, disable this checkbox to use the **Metallic** property. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-normal-map.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-normal-map.md new file mode 100644 index 00000000000..41c09a8f6a4 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-normal-map.md @@ -0,0 +1,4 @@ + +**UseNormalMap** +Toggles whether the material uses the **NormalMap** property. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-opacity-map(mask).md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-opacity-map(mask).md new file mode 100644 index 00000000000..eaad5a4ec85 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-opacity-map(mask).md @@ -0,0 +1,4 @@ + +**UseOpacityMap** +Toggles whether the material uses the alpha channel of the **ColorMap** texture or the red channel of the **MaskMap** texture to set the opacity of its surface. Enable this checkbox to use the alpha channel of the **ColorMap** texture, disable this checkbox to use the red channel of the **MaskMap** texture. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-opacity-map.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-opacity-map.md new file mode 100644 index 00000000000..fd20f46cc52 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-opacity-map.md @@ -0,0 +1,4 @@ + +**UseOpacityMap** +Toggles whether the material uses the alpha channel of the **ColorMap** texture or the **Opacity** property to set the opacity of its surface. Enable this checkbox to use the alpha channel of the **ColorMap** texture, disable this checkbox to use the **Opacity** property. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-roughness-map.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-roughness-map.md new file mode 100644 index 00000000000..338cc5fb1dc --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/use-roughness-map.md @@ -0,0 +1,4 @@ + +**UseRoughnessMap** +Toggles whether the material uses the **RoughnessMap** property or the **Roughness** property to set the roughness of its surface. Enable this checkbox to use the **RoughnessMap** property, disable this checkbox to use the **Roughness** property. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/uv-offset.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/uv-offset.md new file mode 100644 index 00000000000..6b52ff0d3ed --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/uv-offset.md @@ -0,0 +1,4 @@ + +**UVOffset** +The **X** and **Y** UV offset for all the textures on this material. HDRP uses the **X** and **Y** values to offset these textures across the material’s surface, in object space. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/uv-scale.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/uv-scale.md new file mode 100644 index 00000000000..6595a448a79 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/autodesk-interactive/uv-scale.md @@ -0,0 +1,4 @@ + +**UVScale** +The **X** and **Y** UV tile rate for all the textures on this material. HDRP uses the **X** and **Y** values to scale these textures across the material’s surface, in object space. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/general/double-sided-global-illumination.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/general/double-sided-global-illumination.md new file mode 100644 index 00000000000..d3e7b17099c --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/general/double-sided-global-illumination.md @@ -0,0 +1,4 @@ + +**Double Sided Global Illumination** +When enabled, the lightmapper accounts for both sides of the geometry when calculating Global Illumination. Backfaces are not rendered or added to lightmaps, but get treated as valid when seen from other objects. When using the Progressive Lightmapper, backfaces bounce light using the same emission and albedo as frontfaces. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/general/emission-global-illumination.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/general/emission-global-illumination.md new file mode 100644 index 00000000000..94e629bceae --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/general/emission-global-illumination.md @@ -0,0 +1,4 @@ + +**- Global Illumination** +The mode HDRP uses to determine how color emission interacts with global illumination.
• **Realtime**: Select this option to make emission affect the result of real-time global illumination.
• **Baked**: Select this option to make emission only affect global illumination during the baking process.
• **None**: Select this option to make emission not affect global illumination. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/general/emission.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/general/emission.md new file mode 100644 index 00000000000..dda4f0d6d38 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/general/emission.md @@ -0,0 +1,4 @@ + +**Emission** +Toggles whether emission affects global illumination. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/general/enable-gpu-instancing.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/general/enable-gpu-instancing.md new file mode 100644 index 00000000000..df189c8c80a --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/general/enable-gpu-instancing.md @@ -0,0 +1,4 @@ + +**Enable GPU Instancing** +Enable the checkbox to tell HDRP to render Meshes with the same geometry and Material in one batch when possible. This makes rendering faster. HDRP cannot render Meshes in one batch if they have different Materials, or if the hardware does not support GPU instancing. For example, you cannot [static-batch](https://docs.unity3d.com/Manual/DrawCallBatching.html) GameObjects that have an animation based on the object pivot, but the GPU can instance them. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/general/motion-vector-for-vertex-animation.md b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/general/motion-vector-for-vertex-animation.md new file mode 100644 index 00000000000..14d1153183c --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/snippets/shader-properties/general/motion-vector-for-vertex-animation.md @@ -0,0 +1,4 @@ + +**Motion Vector For Vertex Animation** +Enable the checkbox to make HDRP write motion vectors for GameObjects that use vertex animation. This removes the ghosting that vertex animation can cause. + \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/DiffusionProfile/DiffusionProfileSettingsEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Material/DiffusionProfile/DiffusionProfileSettingsEditor.cs index 13a74a6bd0c..e3d84021f4e 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/DiffusionProfile/DiffusionProfileSettingsEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/DiffusionProfile/DiffusionProfileSettingsEditor.cs @@ -131,7 +131,9 @@ public override void OnInspectorGUI() serializedObject.ApplyModifiedProperties(); - if (scope.changed) + // NOTE: We cannot change only upon scope changed since there is no callback when Reset is triggered for Editor and the scope is not changed when Reset is called. + // The following operations are not super cheap, but are not overly expensive, so we instead trigger the change every time inspector is drawn. + // if (scope.changed) { // Validate and update the cache for this profile only profile.objReference.Validate(); diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/TerrainLit/TerrainLitGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/TerrainLit/TerrainLitGUI.cs index 109e635d735..01adc853dc0 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/TerrainLit/TerrainLitGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/TerrainLit/TerrainLitGUI.cs @@ -65,12 +65,12 @@ private class StylesLayer public readonly GUIContent defaultValues = new GUIContent("Channel Default Values"); public readonly GUIContent metallic = new GUIContent("R: Metallic"); public readonly GUIContent ao = new GUIContent("G: AO"); - public readonly GUIContent height = new GUIContent("B: Height"); - public readonly GUIContent heightParametrization = new GUIContent("Parametrization"); - public readonly GUIContent heightAmplitude = new GUIContent("Amplitude (cm)"); - public readonly GUIContent heightBase = new GUIContent("Base (cm)"); - public readonly GUIContent heightMin = new GUIContent("Min (cm)"); - public readonly GUIContent heightMax = new GUIContent("Max (cm)"); + public readonly GUIContent height = new GUIContent("B: Height", "Specifies the Height Map for this Material."); + public readonly GUIContent heightParametrization = new GUIContent("Parametrization", "Specifies the parametrization method for the Height Map."); + public readonly GUIContent heightAmplitude = new GUIContent("Amplitude", "Sets the amplitude of the Height Map (in centimeters)."); + public readonly GUIContent heightBase = new GUIContent("Base", "Controls the base of the Height Map (between 0 and 1)."); + public readonly GUIContent heightMin = new GUIContent("Min", "Sets the minimum value in the Height Map (in centimeters)."); + public readonly GUIContent heightMax = new GUIContent("Max", "Sets the maximum value in the Height Map (in centimeters)."); public readonly GUIContent heightCm = new GUIContent("B: Height (cm)"); public readonly GUIContent smoothness = new GUIContent("A: Smoothness"); } @@ -309,8 +309,8 @@ bool ITerrainLayerCustomUI.OnTerrainLayerGUI(TerrainLayer terrainLayer, Terrain float amplitude = Mathf.Max(maskMapRemapMax.z - maskMapRemapMin.z, Mathf.Epsilon); // to avoid divide by zero float heightBase = -maskMapRemapMin.z / amplitude; amplitude = EditorGUILayout.FloatField(styles.heightAmplitude, amplitude * 100) / 100; - heightBase = EditorGUILayout.FloatField(styles.heightBase, heightBase * 100) / 100; - maskMapRemapMin.z = heightBase * amplitude; + heightBase = EditorGUILayout.Slider(styles.heightBase, heightBase, 0.0f, 1.0f); + maskMapRemapMin.z = -heightBase * amplitude; maskMapRemapMax.z = (1 - heightBase) * amplitude; } else diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs index a8e6baff563..34c414e3309 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs @@ -1027,10 +1027,13 @@ void RegisterRenderingDebug() }); } - widgetList.AddRange(new DebugUI.Widget[] + if (HDRenderPipeline.currentAsset?.currentPlatformRenderPipelineSettings.supportMSAA ?? true) { - new DebugUI.EnumField { displayName = "MSAA Samples", getter = () => (int)data.msaaSamples, setter = value => data.msaaSamples = (MSAASamples)value, enumNames = s_MsaaSamplesDebugStrings, enumValues = s_MsaaSamplesDebugValues, getIndex = () => data.msaaSampleDebugModeEnumIndex, setIndex = value => data.msaaSampleDebugModeEnumIndex = value }, - }); + widgetList.AddRange(new DebugUI.Widget[] + { + new DebugUI.EnumField { displayName = "MSAA Samples", getter = () => (int)data.msaaSamples, setter = value => data.msaaSamples = (MSAASamples)value, enumNames = s_MsaaSamplesDebugStrings, enumValues = s_MsaaSamplesDebugValues, getIndex = () => data.msaaSampleDebugModeEnumIndex, setIndex = value => data.msaaSampleDebugModeEnumIndex = value }, + }); + } widgetList.AddRange(new DebugUI.Widget[] { diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs index 18463cf9f72..b61c546394c 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs @@ -1458,6 +1458,7 @@ internal Light legacyLight internal MeshRenderer emissiveMeshRenderer { get; private set; } #if UNITY_EDITOR + bool m_NeedsPrefabInstanceCheck = false; bool needRefreshPrefabInstanceEmissiveMeshes = false; #endif bool needRefreshEmissiveMeshesFromTimeLineUpdate = false; @@ -1593,7 +1594,7 @@ public int areaLightEmissiveMeshLayer return; m_AreaLightEmissiveMeshLayer = value; - if (emissiveMeshRenderer != null && !emissiveMeshRenderer.Equals(null)) + if (emissiveMeshRenderer != null && !emissiveMeshRenderer.Equals(null) && m_AreaLightEmissiveMeshLayer != -1) { emissiveMeshRenderer.gameObject.layer = m_AreaLightEmissiveMeshLayer; } @@ -2156,6 +2157,14 @@ void LateUpdate() #endif #if UNITY_EDITOR + + // If modification are due to change on prefab asset that are non overridden on this prefab instance + if (m_NeedsPrefabInstanceCheck && PrefabUtility.IsPartOfPrefabInstance(this) && ((PrefabUtility.GetCorrespondingObjectFromOriginalSource(this) as HDAdditionalLightData)?.needRefreshPrefabInstanceEmissiveMeshes ?? false)) + { + needRefreshPrefabInstanceEmissiveMeshes = true; + } + m_NeedsPrefabInstanceCheck = false; + // Update the list of overlapping lights for the LightOverlap scene view mode if (IsOverlapping()) s_overlappingHDLights.Add(this); @@ -2362,19 +2371,15 @@ void OnValidate() DisableCachedShadowSlot(); m_ShadowMapRenderedSinceLastRequest = false; - if (emissiveMeshRenderer != null && !emissiveMeshRenderer.Equals(null)) + if (emissiveMeshRenderer != null && !emissiveMeshRenderer.Equals(null) && m_AreaLightEmissiveMeshLayer != -1) { emissiveMeshRenderer.gameObject.layer = m_AreaLightEmissiveMeshLayer; } #if UNITY_EDITOR - // If modification are due to change on prefab asset that are non overridden on this prefab instance - if (PrefabUtility.IsPartOfPrefabInstance(this) && ((PrefabUtility.GetCorrespondingObjectFromOriginalSource(this) as HDAdditionalLightData)?.needRefreshPrefabInstanceEmissiveMeshes ?? false)) - { - // As we cannot Create/Destroy in OnValidate, delay call to next Update - // To do this, wo set the same flag on prefab instances - needRefreshPrefabInstanceEmissiveMeshes = true; - } + // If modification are due to change on prefab asset, we want to have prefab instances to self-update, but we cannot check in OnValidate if this is part of + // prefab instance. So we delay the check on next update (and before teh LateUpdate logic) + m_NeedsPrefabInstanceCheck = true; #endif } @@ -2679,7 +2684,9 @@ void UpdateShapeSize() shapeHeight = m_ShapeHeight; #if UNITY_EDITOR - legacyLight.areaSize = new Vector2(shapeWidth, shapeHeight); + // We don't want to update the disc area since their shape is largely handled by builtin. + if (GetLightTypeAndShape() != HDLightTypeAndShape.DiscArea) + legacyLight.areaSize = new Vector2(shapeWidth, shapeHeight); #endif } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/DeferredTile.shader b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/DeferredTile.shader index bc68896e4f4..c04163b0922 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/DeferredTile.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/DeferredTile.shader @@ -38,7 +38,7 @@ Shader "Hidden/HDRP/DeferredTile" #pragma multi_compile _ OUTPUT_SPLIT_LIGHTING // Split lighting is utilized during the SSS pass. #pragma multi_compile _ SHADOWS_SHADOWMASK /// Variant with and without shadowmask - #pragma multi_compile VARIANT0 VARIANT1 VARIANT2 VARIANT3 VARIANT4 VARIANT5 VARIANT6 VARIANT7 VARIANT8 VARIANT9 VARIANT10 VARIANT11 VARIANT12 VARIANT13 VARIANT14 VARIANT15 VARIANT16 VARIANT17 VARIANT18 VARIANT19 VARIANT20 VARIANT21 VARIANT22 VARIANT23 VARIANT24 VARIANT25 VARIANT26 VARIANT27 VARIANT28 + #pragma multi_compile_local VARIANT0 VARIANT1 VARIANT2 VARIANT3 VARIANT4 VARIANT5 VARIANT6 VARIANT7 VARIANT8 VARIANT9 VARIANT10 VARIANT11 VARIANT12 VARIANT13 VARIANT14 VARIANT15 VARIANT16 VARIANT17 VARIANT18 VARIANT19 VARIANT20 VARIANT21 VARIANT22 VARIANT23 VARIANT24 VARIANT25 VARIANT26 VARIANT27 VARIANT28 #define USE_INDIRECT // otherwise TileVariantToFeatureFlags() will not be defined in Lit.hlsl!!! diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalSystem.cs index 55c80ef43a1..f0b8c3136b6 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalSystem.cs @@ -1021,7 +1021,11 @@ public void AddTexture(CommandBuffer cmd, TextureScaleBias textureScaleBias) { if (textureScaleBias.m_Texture != null) { - if (!Atlas.AddTexture(cmd, ref textureScaleBias.m_ScaleBias, textureScaleBias.m_Texture)) + if (Atlas.IsCached(out textureScaleBias.m_ScaleBias, textureScaleBias.m_Texture)) + { + Atlas.UpdateTexture(cmd, textureScaleBias.m_Texture, ref textureScaleBias.m_ScaleBias); + } + else if (!Atlas.AddTexture(cmd, ref textureScaleBias.m_ScaleBias, textureScaleBias.m_Texture)) { m_AllocationSuccess = false; } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs index 4ba309b942b..d678dd3d112 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs @@ -129,6 +129,8 @@ public void Reset() isFirstFrame = true; cameraFrameCount = 0; resetPostProcessingHistory = true; + volumetricHistoryIsValid = false; + colorPyramidHistoryIsValid = false; } /// diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LookDev.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LookDev.cs index a2d41634420..62dc8061a1e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LookDev.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LookDev.cs @@ -5,10 +5,6 @@ namespace UnityEngine.Rendering.HighDefinition { public partial class HDRenderPipeline : IDataProvider { -#if UNITY_EDITOR - int m_LookDevVolumeProfileHash = -1; -#endif - struct LookDevDataForHDRP { public HDAdditionalCameraData additionalCameraData; @@ -16,21 +12,22 @@ struct LookDevDataForHDRP public VisualEnvironment visualEnvironment; public HDRISky sky; public Volume volume; + public int currentVolumeProfileHash; } #if UNITY_EDITOR - bool UpdateVolumeProfile(Volume volume, out VisualEnvironment visualEnvironment, out HDRISky sky) + bool UpdateVolumeProfile(Volume volume, out VisualEnvironment visualEnvironment, out HDRISky sky, ref int volumeProfileHash) { HDRenderPipelineAsset hdrpAsset = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset; if (hdrpAsset.defaultLookDevProfile == null) hdrpAsset.defaultLookDevProfile = hdrpAsset.renderPipelineEditorResources.lookDev.defaultLookDevVolumeProfile; int newHashCode = hdrpAsset.defaultLookDevProfile.GetHashCode(); - if (newHashCode != m_LookDevVolumeProfileHash) + if (newHashCode != volumeProfileHash) { VolumeProfile oldProfile = volume.sharedProfile; - m_LookDevVolumeProfileHash = newHashCode; + volumeProfileHash = newHashCode; VolumeProfile profile = ScriptableObject.Instantiate(hdrpAsset.defaultLookDevProfile); profile.hideFlags = HideFlags.HideAndDontSave; @@ -118,8 +115,8 @@ void IDataProvider.FirstInitScene(StageRuntimeInterface SRI) #if UNITY_EDITOR // Make sure we invalidate the current volume when first loading a scene. - m_LookDevVolumeProfileHash = -1; - UpdateVolumeProfile(volume, out var visualEnvironment, out var sky); + int volumeProfileHash = -1; + UpdateVolumeProfile(volume, out var visualEnvironment, out var sky, ref volumeProfileHash); SRI.SRPData = new LookDevDataForHDRP() { @@ -127,7 +124,8 @@ void IDataProvider.FirstInitScene(StageRuntimeInterface SRI) additionalLightData = additionalLightData, visualEnvironment = visualEnvironment, sky = sky, - volume = volume + volume = volume, + currentVolumeProfileHash = volumeProfileHash }; #else //remove unassigned warnings when building @@ -174,11 +172,13 @@ void IDataProvider.OnBeginRendering(StageRuntimeInterface SRI) { LookDevDataForHDRP data = (LookDevDataForHDRP)SRI.SRPData; #if UNITY_EDITOR + int currentHash = data.currentVolumeProfileHash; // The default volume can change in the HDRP asset so if it does we need to re-instantiate it. - if (UpdateVolumeProfile(data.volume, out var visualEnv, out var sky)) + if (UpdateVolumeProfile(data.volume, out var visualEnv, out var sky, ref currentHash)) { data.sky = sky; data.visualEnvironment = visualEnv; + data.currentVolumeProfileHash = currentHash; SRI.SRPData = data; } #endif diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index f5f14d65d78..b81d01d1f9b 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -477,9 +477,6 @@ public HDRenderPipeline(HDRenderPipelineAsset asset, HDRenderPipelineAsset defau // TODO : Bind this directly to the debug menu instead of having an intermediate value m_MSAASamples = m_Asset ? m_Asset.currentPlatformRenderPipelineSettings.msaaSampleCount : MSAASamples.None; - // Propagate it to the debug menu - m_DebugDisplaySettings.data.msaaSamples = m_MSAASamples; - m_MRTTransparentMotionVec = new RenderTargetIdentifier[2]; if (m_RayTracingSupported) @@ -1385,6 +1382,7 @@ protected override void Render(ScriptableRenderContext renderContext, Camera[] c cullingResults = req.cullingResults; skipClearCullingResults.Add(req.index); needCulling = false; + m_SkyManager.UpdateCurrentSkySettings(hdCamera); } } } @@ -1997,7 +1995,10 @@ AOVRequestData aovRequest else { // Make sure we are in sync with the debug menu for the msaa count - m_MSAASamples = m_DebugDisplaySettings.data.msaaSamples; + m_MSAASamples = (m_DebugDisplaySettings.data.msaaSamples != MSAASamples.None) ? + m_DebugDisplaySettings.data.msaaSamples : + m_Asset.currentPlatformRenderPipelineSettings.msaaSampleCount; + m_SharedRTManager.SetNumMSAASamples(m_MSAASamples); m_DebugDisplaySettings.UpdateCameraFreezeOptions(); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/XR/XRSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/XR/XRSystem.cs index bb117be26be..dea6afa4627 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/XR/XRSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/XR/XRSystem.cs @@ -132,13 +132,21 @@ internal int GetMaxViews() { // custom layout in used } +#if ENABLE_VR && ENABLE_XR_MODULE else if (xrActive && xrSupported) { // Disable vsync on the main display when rendering to a XR device QualitySettings.vSyncCount = 0; + if(display != null) + { + display.zNear = camera.nearClipPlane; + display.zFar = camera.farClipPlane; + } + CreateLayoutFromXrSdk(camera, singlePassAllowed); } +#endif else { AddPassToFrame(camera, emptyPass); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs index 63543b12ea4..42fe8b19026 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs @@ -815,8 +815,10 @@ public void UpdateEnvironment(HDCamera hdCamera, ScriptableRenderContext renderC StaticLightingSky staticLightingSky = GetStaticLightingSky(); #if UNITY_EDITOR // In the editor, we might need the static sky ready for baking lightmaps/lightprobes regardless of the current ambient mode so we force it to update in this case if it's not been computed yet.. - // We don't test if the hash of the static sky has changed here because it depends on the sun direction and in the case of LookDev, sun will be different from the main rendering so it will induce improper recomputation. - forceStaticUpdate = staticLightingSky != null && m_StaticLightingSky.skyParametersHash == -1; ; + // We always force an update of the static sky when we're in scene view mode. Previous behaviour was to prevent forced updates if the hash of the static sky was non-null, but this was preventing + // the lightmapper from updating in response to changes in environment. See GFXGI-237 for a better description of this issue. + + forceStaticUpdate = hdCamera.camera.cameraType == CameraType.SceneView; #endif if ((ambientMode == SkyAmbientMode.Static || forceStaticUpdate) && hdCamera.camera.cameraType != CameraType.Preview) { diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs.orig b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs.orig new file mode 100644 index 00000000000..c62a63c37bc --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs.orig @@ -0,0 +1,1089 @@ +using System; +using System.Linq; +using System.Collections.Generic; +using UnityEngine.Experimental.Rendering; + +namespace UnityEngine.Rendering.HighDefinition +{ + /// + /// Resolution of the sky reflection cubemap. + /// + [Serializable] + public enum SkyResolution + { + /// 128x128 per face. + SkyResolution128 = 128, + /// 256x256 per face. + SkyResolution256 = 256, + /// 512x512 per face. + SkyResolution512 = 512, + /// 1024x1024 per face. + SkyResolution1024 = 1024, + /// 2048x2048 per face. + SkyResolution2048 = 2048, + /// 4096x4096 per face. + SkyResolution4096 = 4096 + } + + /// + /// Environment lighting update mode. + /// + public enum EnvironmentUpdateMode + { + /// Environment lighting is updated when the sky has changed. + OnChanged = 0, + /// Environment lighting is updated on demand. + OnDemand, + /// Environment lighting is updated in real time. + Realtime + } + + /// + /// Parameters passed to sky rendering functions. + /// + public class BuiltinSkyParameters + { + /// Camera used for rendering. + public HDCamera hdCamera; + /// Matrix mapping pixel coordinate to view direction. + public Matrix4x4 pixelCoordToViewDirMatrix; + /// World space camera position. + public Vector3 worldSpaceCameraPos; + /// Camera view matrix. + public Matrix4x4 viewMatrix; + /// Screen size: Width, height, inverse width, inverse height. + public Vector4 screenSize; + /// Command buffer used for rendering. + public CommandBuffer commandBuffer; + /// Current sun light. + public Light sunLight; + /// Color buffer used for rendering. + public RTHandle colorBuffer; + /// Depth buffer used for rendering. + public RTHandle depthBuffer; + /// Current frame index. + public int frameIndex; + /// Current sky settings. + public SkySettings skySettings; + /// Current debug dsplay settings. + public DebugDisplaySettings debugSettings; + /// Null color buffer render target identifier. + public static RenderTargetIdentifier nullRT = -1; + } + + struct CachedSkyContext + { + public Type type; + public SkyRenderingContext renderingContext; + public int hash; + public int refCount; + + public void Reset() + { + // We keep around the renderer and the rendering context to avoid useless allocation if they get reused. + hash = 0; + refCount = 0; + } + + public void Cleanup() + { + Reset(); + + if (renderingContext != null) + { + renderingContext.Cleanup(); + renderingContext = null; + } + } + } + + class SkyManager + { + Material m_StandardSkyboxMaterial; // This is the Unity standard skybox material. Used to pass the correct cubemap to Enlighten. + Material m_BlitCubemapMaterial; + Material m_OpaqueAtmScatteringMaterial; + + SphericalHarmonicsL2 m_BlackAmbientProbe = new SphericalHarmonicsL2(); + + bool m_UpdateRequired = false; + bool m_StaticSkyUpdateRequired = false; + int m_Resolution; + + // Sky used for static lighting. It will be used for ambient lighting if Ambient Mode is set to Static (even when realtime GI is enabled) + // It will also be used for lightmap and light probe baking + SkyUpdateContext m_StaticLightingSky = new SkyUpdateContext(); + + // This interpolation volume stack is used to interpolate the lighting override separately from the visual sky. + // If a sky setting is present in this volume then it will be used for lighting override. + public VolumeStack lightingOverrideVolumeStack { get; private set; } + public LayerMask lightingOverrideLayerMask { get; private set; } = -1; + + static Dictionary m_SkyTypesDict = null; + public static Dictionary skyTypesDict { get { if (m_SkyTypesDict == null) UpdateSkyTypes(); return m_SkyTypesDict; } } + + // This list will hold the static lighting sky that should be used for baking ambient probe. + // In practice we will always use the last one registered but we use a list to be able to roll back to the previous one once the user deletes the superfluous instances. + private static List m_StaticLightingSkies = new List(); + + // Only show the procedural sky upgrade message once + static bool logOnce = true; + + // This boolean here is only to track the first frame after a domain reload or creation. + bool m_RequireWaitForAsyncReadBackRequest = true; + + MaterialPropertyBlock m_OpaqueAtmScatteringBlock; + +#if UNITY_EDITOR + // For Preview windows we want to have a 'fixed' sky, so we can display chrome metal and have always the same look + HDRISky m_DefaultPreviewSky; +#endif + + // Shared resources for sky rendering. + IBLFilterBSDF[] m_IBLFilterArray; + RTHandle m_SkyboxBSDFCubemapIntermediate; + Vector4 m_CubemapScreenSize; + Matrix4x4[] m_facePixelCoordToViewDirMatrices = new Matrix4x4[6]; + Matrix4x4[] m_CameraRelativeViewMatrices = new Matrix4x4[6]; + BuiltinSkyParameters m_BuiltinParameters = new BuiltinSkyParameters(); + ComputeShader m_ComputeAmbientProbeCS; + readonly int m_AmbientProbeOutputBufferParam = Shader.PropertyToID("_AmbientProbeOutputBuffer"); + readonly int m_AmbientProbeInputCubemap = Shader.PropertyToID("_AmbientProbeInputCubemap"); + int m_ComputeAmbientProbeKernel; + CubemapArray m_BlackCubemapArray; + + // 2 by default: Static sky + one dynamic. Will grow if needed. + DynamicArray m_CachedSkyContexts = new DynamicArray(2); + + public SkyManager() + { +#if UNITY_EDITOR + UnityEditor.Lightmapping.bakeStarted += OnBakeStarted; + #endif + } + + ~SkyManager() + { +#if UNITY_EDITOR + UnityEditor.Lightmapping.bakeStarted -= OnBakeStarted; +#endif + } + + internal static SkySettings GetSkySetting(VolumeStack stack) + { + var visualEnv = stack.GetComponent(); + int skyID = visualEnv.skyType.value; + Type skyType; + if (skyTypesDict.TryGetValue(skyID, out skyType)) + { + return (SkySettings)stack.GetComponent(skyType); + } + else + { + if (skyID == (int)SkyType.Procedural && logOnce) + { + Debug.LogError("You are using the deprecated Procedural Sky in your Scene. You can still use it but, to do so, you must install it separately. To do this, open the Package Manager window and import the 'Procedural Sky' sample from the HDRP package page, then close and re-open your project without saving."); + logOnce = false; + } + + return null; + } + } + + static void UpdateSkyTypes() + { + if (m_SkyTypesDict == null) + { + m_SkyTypesDict = new Dictionary(); + + var skyTypes = CoreUtils.GetAllTypesDerivedFrom().Where(t => !t.IsAbstract); + foreach (Type skyType in skyTypes) + { + var uniqueIDs = skyType.GetCustomAttributes(typeof(SkyUniqueID), false); + if (uniqueIDs.Length == 0) + { + Debug.LogWarningFormat("Missing attribute SkyUniqueID on class {0}. Class won't be registered as an available sky.", skyType); + } + else + { + int uniqueID = ((SkyUniqueID)uniqueIDs[0]).uniqueID; + if (uniqueID == 0) + { + Debug.LogWarningFormat("0 is a reserved SkyUniqueID and is used in class {0}. Class won't be registered as an available sky.", skyType); + continue; + } + + Type value; + if (m_SkyTypesDict.TryGetValue(uniqueID, out value)) + { + Debug.LogWarningFormat("SkyUniqueID {0} used in class {1} is already used in class {2}. Class won't be registered as an available sky.", uniqueID, skyType, value); + continue; + } + + m_SkyTypesDict.Add(uniqueID, skyType); + } + } + } + } + + public void UpdateCurrentSkySettings(HDCamera hdCamera) + { + hdCamera.UpdateCurrentSky(this); + } + + public void SetGlobalSkyData(CommandBuffer cmd, HDCamera hdCamera) + { + if (IsCachedContextValid(hdCamera.lightingSky)) + { + var renderer = hdCamera.lightingSky.skyRenderer; + if (renderer != null) + { + m_BuiltinParameters.skySettings = hdCamera.lightingSky.skySettings; + renderer.SetGlobalSkyData(cmd, m_BuiltinParameters); + } + } + } + +#if UNITY_EDITOR + internal HDRISky GetDefaultPreviewSkyInstance() + { + if (m_DefaultPreviewSky == null) + { + m_DefaultPreviewSky = ScriptableObject.CreateInstance(); + m_DefaultPreviewSky.hdriSky.overrideState = true; + m_DefaultPreviewSky.hdriSky.value = HDRenderPipeline.currentAsset?.renderPipelineResources?.textures?.defaultHDRISky; + } + + return m_DefaultPreviewSky; + } + +#endif + + public void Build(HDRenderPipelineAsset hdAsset, RenderPipelineResources defaultResources, IBLFilterBSDF[] iblFilterBSDFArray) + { + var hdrp = HDRenderPipeline.defaultAsset; + + m_Resolution = (int)hdAsset.currentPlatformRenderPipelineSettings.lightLoopSettings.skyReflectionSize; + m_IBLFilterArray = iblFilterBSDFArray; + + m_StandardSkyboxMaterial = CoreUtils.CreateEngineMaterial(defaultResources.shaders.skyboxCubemapPS); + m_BlitCubemapMaterial = CoreUtils.CreateEngineMaterial(defaultResources.shaders.blitCubemapPS); + + m_OpaqueAtmScatteringMaterial = CoreUtils.CreateEngineMaterial(defaultResources.shaders.opaqueAtmosphericScatteringPS); + m_OpaqueAtmScatteringBlock = new MaterialPropertyBlock(); + + m_ComputeAmbientProbeCS = hdrp.renderPipelineResources.shaders.ambientProbeConvolutionCS; + m_ComputeAmbientProbeKernel = m_ComputeAmbientProbeCS.FindKernel("AmbientProbeConvolution"); + + lightingOverrideVolumeStack = VolumeManager.instance.CreateStack(); + lightingOverrideLayerMask = hdAsset.currentPlatformRenderPipelineSettings.lightLoopSettings.skyLightingOverrideLayerMask; + + int resolution = (int)hdAsset.currentPlatformRenderPipelineSettings.lightLoopSettings.skyReflectionSize; + m_SkyboxBSDFCubemapIntermediate = RTHandles.Alloc(resolution, resolution, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureDimension.Cube, useMipMap: true, autoGenerateMips: false, filterMode: FilterMode.Trilinear, name: "SkyboxBSDFIntermediate"); + m_CubemapScreenSize = new Vector4((float)resolution, (float)resolution, 1.0f / (float)resolution, 1.0f / (float)resolution); + + var cubeProj = Matrix4x4.Perspective(90.0f, 1.0f, 0.01f, 1.0f); + + for (int i = 0; i < 6; ++i) + { + var lookAt = Matrix4x4.LookAt(Vector3.zero, CoreUtils.lookAtList[i], CoreUtils.upVectorList[i]); + var worldToView = lookAt * Matrix4x4.Scale(new Vector3(1.0f, 1.0f, -1.0f)); // Need to scale -1.0 on Z to match what is being done in the camera.wolrdToCameraMatrix API. ... + + m_facePixelCoordToViewDirMatrices[i] = HDUtils.ComputePixelCoordToWorldSpaceViewDirectionMatrix(0.5f * Mathf.PI, Vector2.zero, m_CubemapScreenSize, worldToView, true); + m_CameraRelativeViewMatrices[i] = worldToView; + } + + InitializeBlackCubemapArray(); + } + + void InitializeBlackCubemapArray() + { + if (m_BlackCubemapArray == null) + { + m_BlackCubemapArray = new CubemapArray(1, m_IBLFilterArray.Length, TextureFormat.RGBA32, false) + { + hideFlags = HideFlags.HideAndDontSave, + wrapMode = TextureWrapMode.Repeat, + wrapModeV = TextureWrapMode.Clamp, + filterMode = FilterMode.Trilinear, + anisoLevel = 0, + name = "BlackCubemapArray" + }; + + Color32[] black = { new Color32(0, 0, 0, 0) }; + + for (int element = 0; element < m_IBLFilterArray.Length; ++element) + { + for (int i = 0; i < 6; i++) + m_BlackCubemapArray.SetPixels32(black, (CubemapFace)i, element); + } + + m_BlackCubemapArray.Apply(); + } + } + + + public void Cleanup() + { + CoreUtils.Destroy(m_StandardSkyboxMaterial); + CoreUtils.Destroy(m_BlitCubemapMaterial); + CoreUtils.Destroy(m_OpaqueAtmScatteringMaterial); + + RTHandles.Release(m_SkyboxBSDFCubemapIntermediate); + CoreUtils.Destroy(m_BlackCubemapArray); + + for (int i = 0; i < m_CachedSkyContexts.size; ++i) + m_CachedSkyContexts[i].Cleanup(); + + m_StaticLightingSky.Cleanup(); + lightingOverrideVolumeStack.Dispose(); + +#if UNITY_EDITOR + CoreUtils.Destroy(m_DefaultPreviewSky); +#endif + } + + public bool IsLightingSkyValid(HDCamera hdCamera) + { + return hdCamera.lightingSky.IsValid(); + } + + public bool IsVisualSkyValid(HDCamera hdCamera) + { + return hdCamera.visualSky.IsValid(); + } + + SphericalHarmonicsL2 GetAmbientProbe(SkyUpdateContext skyContext) + { + if (skyContext.IsValid() && IsCachedContextValid(skyContext)) + { + ref var context = ref m_CachedSkyContexts[skyContext.cachedSkyRenderingContextId]; + return context.renderingContext.ambientProbe; + } + else + { + return m_BlackAmbientProbe; + } + } + + Texture GetSkyCubemap(SkyUpdateContext skyContext) + { + if (skyContext.IsValid() && IsCachedContextValid(skyContext)) + { + ref var context = ref m_CachedSkyContexts[skyContext.cachedSkyRenderingContextId]; + return context.renderingContext.skyboxCubemapRT; + } + else + { + return CoreUtils.blackCubeTexture; + } + } + + Texture GetReflectionTexture(SkyUpdateContext skyContext) + { + if (skyContext.IsValid() && IsCachedContextValid(skyContext)) + { + ref var context = ref m_CachedSkyContexts[skyContext.cachedSkyRenderingContextId]; + return context.renderingContext.skyboxBSDFCubemapArray; + } + else + { + return m_BlackCubemapArray; + } + } + + public Texture GetSkyReflection(HDCamera hdCamera) + { + return GetReflectionTexture(hdCamera.lightingSky); + } + + // Return the value of the ambient probe + internal SphericalHarmonicsL2 GetAmbientProbe(HDCamera hdCamera) + { + // If a camera just returns from being disabled, sky is not setup yet for it. + if (hdCamera.lightingSky == null && hdCamera.skyAmbientMode == SkyAmbientMode.Dynamic) + { + return m_BlackAmbientProbe; + } + + if (hdCamera.skyAmbientMode == SkyAmbientMode.Static) + { + return GetAmbientProbe(m_StaticLightingSky); + } + + return GetAmbientProbe(hdCamera.lightingSky); + } + + internal bool HasSetValidAmbientProbe(HDCamera hdCamera) + { + SkyAmbientMode ambientMode = hdCamera.volumeStack.GetComponent().skyAmbientMode.value; + if (ambientMode == SkyAmbientMode.Static) + return true; + + if (hdCamera.skyAmbientMode == SkyAmbientMode.Dynamic && hdCamera.lightingSky != null && + hdCamera.lightingSky.IsValid() && IsCachedContextValid(hdCamera.lightingSky)) + { + ref CachedSkyContext cachedContext = ref m_CachedSkyContexts[hdCamera.lightingSky.cachedSkyRenderingContextId]; + var renderingContext = cachedContext.renderingContext; + return renderingContext.ambientProbeIsReady; + } + + return false; + + } + + internal void SetupAmbientProbe(HDCamera hdCamera) + { + // Working around GI current system + // When using baked lighting, setting up the ambient probe should be sufficient => We only need to update RenderSettings.ambientProbe with either the static or visual sky ambient probe (computed from GPU) + // When using real time GI. Enlighten will pull sky information from Skybox material. So in order for dynamic GI to work, we update the skybox material texture and then set the ambient mode to SkyBox + // Problem: We can't check at runtime if realtime GI is enabled so we need to take extra care (see useRealtimeGI usage below) + + // Order is important! + RenderSettings.ambientMode = AmbientMode.Custom; // Needed to specify ourselves the ambient probe (this will update internal ambient probe data passed to shaders) + RenderSettings.ambientProbe = GetAmbientProbe(hdCamera); + + // If a camera just returns from being disabled, sky is not setup yet for it. + if (hdCamera.lightingSky == null && hdCamera.skyAmbientMode == SkyAmbientMode.Dynamic) + { + return; + } + + // Workaround in the editor: + // When in the editor, if we use baked lighting, we need to setup the skybox material with the static lighting texture otherwise when baking, the dynamic texture will be used + bool useRealtimeGI = true; +#if UNITY_EDITOR +#pragma warning disable 618 + useRealtimeGI = UnityEditor.Lightmapping.realtimeGI; +#pragma warning restore 618 +#endif + m_StandardSkyboxMaterial.SetTexture("_Tex", GetSkyCubemap((hdCamera.skyAmbientMode != SkyAmbientMode.Static && useRealtimeGI) ? hdCamera.lightingSky : m_StaticLightingSky)); + + // This is only needed if we use realtime GI otherwise enlighten won't get the right sky information + RenderSettings.skybox = m_StandardSkyboxMaterial; // Setup this material as the default to be use in RenderSettings + RenderSettings.ambientIntensity = 1.0f; + RenderSettings.ambientMode = AmbientMode.Skybox; // Force skybox for our HDRI + RenderSettings.reflectionIntensity = 1.0f; + RenderSettings.customReflection = null; + } + + void BlitCubemap(CommandBuffer cmd, Cubemap source, RenderTexture dest) + { + var propertyBlock = new MaterialPropertyBlock(); + + for (int i = 0; i < 6; ++i) + { + CoreUtils.SetRenderTarget(cmd, dest, ClearFlag.None, 0, (CubemapFace)i); + propertyBlock.SetTexture("_MainTex", source); + propertyBlock.SetFloat("_faceIndex", (float)i); + cmd.DrawProcedural(Matrix4x4.identity, m_BlitCubemapMaterial, 0, MeshTopology.Triangles, 3, 1, propertyBlock); + } + + // Generate mipmap for our cubemap + Debug.Assert(dest.autoGenerateMips == false); + cmd.GenerateMips(dest); + } + + void RenderSkyToCubemap(SkyUpdateContext skyContext) + { + using (new ProfilingScope(m_BuiltinParameters.commandBuffer, ProfilingSampler.Get(HDProfileId.RenderSkyToCubemap))) + { + var renderingContext = m_CachedSkyContexts[skyContext.cachedSkyRenderingContextId].renderingContext; + var renderer = skyContext.skyRenderer; + + for (int i = 0; i < 6; ++i) + { + m_BuiltinParameters.pixelCoordToViewDirMatrix = m_facePixelCoordToViewDirMatrices[i]; + m_BuiltinParameters.viewMatrix = m_CameraRelativeViewMatrices[i]; + m_BuiltinParameters.colorBuffer = renderingContext.skyboxCubemapRT; + m_BuiltinParameters.depthBuffer = null; + + CoreUtils.SetRenderTarget(m_BuiltinParameters.commandBuffer, renderingContext.skyboxCubemapRT, ClearFlag.None, 0, (CubemapFace)i); + renderer.RenderSky(m_BuiltinParameters, true, skyContext.skySettings.includeSunInBaking.value); + } + + // Generate mipmap for our cubemap + Debug.Assert(renderingContext.skyboxCubemapRT.rt.autoGenerateMips == false); + m_BuiltinParameters.commandBuffer.GenerateMips(renderingContext.skyboxCubemapRT); + } + } + + void RenderCubemapGGXConvolution(SkyUpdateContext skyContext) + { + using (new ProfilingScope(m_BuiltinParameters.commandBuffer, ProfilingSampler.Get(HDProfileId.UpdateSkyEnvironmentConvolution))) + { + var renderingContext = m_CachedSkyContexts[skyContext.cachedSkyRenderingContextId].renderingContext; + var renderer = skyContext.skyRenderer; + + for (int bsdfIdx = 0; bsdfIdx < m_IBLFilterArray.Length; ++bsdfIdx) + { + // First of all filter this cubemap using the target filter + m_IBLFilterArray[bsdfIdx].FilterCubemap(m_BuiltinParameters.commandBuffer, renderingContext.skyboxCubemapRT, m_SkyboxBSDFCubemapIntermediate); + // Then copy it to the cubemap array slice + for (int i = 0; i < 6; ++i) + { + m_BuiltinParameters.commandBuffer.CopyTexture(m_SkyboxBSDFCubemapIntermediate, i, renderingContext.skyboxBSDFCubemapArray, 6 * bsdfIdx + i); + } + } + } + } + + // We do our own hash here because Unity does not provide correct hash for builtin types + // Moreover, we don't want to test every single parameters of the light so we filter them here in this specific function. + int GetSunLightHashCode(Light light) + { + HDAdditionalLightData ald = light.GetComponent(); + unchecked + { + // Sun could influence the sky (like for procedural sky). We need to handle this possibility. If sun property change, then we need to update the sky + int hash = 13; + hash = hash * 23 + light.transform.position.GetHashCode(); + hash = hash * 23 + light.transform.rotation.GetHashCode(); + hash = hash * 23 + light.color.GetHashCode(); + hash = hash * 23 + light.colorTemperature.GetHashCode(); + hash = hash * 23 + light.intensity.GetHashCode(); + // Note: We don't take into account cookie as it doesn't influence GI + if (ald != null) + { + hash = hash * 23 + ald.lightDimmer.GetHashCode(); + } + + return hash; + } + } + + + void AllocateNewRenderingContext(SkyUpdateContext skyContext, int slot, int newHash, bool supportConvolution, in SphericalHarmonicsL2 previousAmbientProbe, string name) + { + Debug.Assert(m_CachedSkyContexts[slot].hash == 0); + ref var context = ref m_CachedSkyContexts[slot]; + context.hash = newHash; + context.refCount = 1; + context.type = skyContext.skySettings.GetSkyRendererType(); + + if (context.renderingContext != null && context.renderingContext.supportsConvolution != supportConvolution) + { + context.renderingContext.Cleanup(); + context.renderingContext = null; + } + + if (context.renderingContext == null) + context.renderingContext = new SkyRenderingContext(m_Resolution, m_IBLFilterArray.Length, supportConvolution, previousAmbientProbe, name); + + skyContext.cachedSkyRenderingContextId = slot; + } + + // Returns whether or not the data should be updated + bool AcquireSkyRenderingContext(SkyUpdateContext updateContext, int newHash, string name = "", bool supportConvolution = true) + { + SphericalHarmonicsL2 cachedAmbientProbe = new SphericalHarmonicsL2(); + // Release the old context if needed. + if (IsCachedContextValid(updateContext)) + { + ref var cachedContext = ref m_CachedSkyContexts[updateContext.cachedSkyRenderingContextId]; + if (newHash != cachedContext.hash || updateContext.skySettings.GetSkyRendererType() != cachedContext.type) + { + // When a sky just changes hash without changing renderer, we need to keep previous ambient probe to avoid flickering transition through a default black probe + if (updateContext.skySettings.GetSkyRendererType() == cachedContext.type) + { + cachedAmbientProbe = cachedContext.renderingContext.ambientProbe; + } + + ReleaseCachedContext(updateContext.cachedSkyRenderingContextId); + } + else + { + // If the hash hasn't changed, keep it. + return false; + } + } + + // Else allocate a new one + int firstFreeContext = -1; + for (int i = 0; i < m_CachedSkyContexts.size; ++i) + { + // Try to find a matching slot + if (m_CachedSkyContexts[i].hash == newHash) + { + m_CachedSkyContexts[i].refCount++; + updateContext.cachedSkyRenderingContextId = i; + updateContext.skyParametersHash = newHash; + return false; + } + + // Find the first available slot in case we don't find a matching one. + if (firstFreeContext == -1 && m_CachedSkyContexts[i].hash == 0) + firstFreeContext = i; + } + + if (name == "") + name = "SkyboxCubemap"; + + if (firstFreeContext != -1) + { + AllocateNewRenderingContext(updateContext, firstFreeContext, newHash, supportConvolution, cachedAmbientProbe, name); + } + else + { + int newContextId = m_CachedSkyContexts.Add(new CachedSkyContext()); + AllocateNewRenderingContext(updateContext, newContextId, newHash, supportConvolution, cachedAmbientProbe, name); + } + + return true; + } + + internal void ReleaseCachedContext(int id) + { + if (id == -1) + return; + + ref var cachedContext = ref m_CachedSkyContexts[id]; + + // This can happen if 2 cameras use the same context and release it in the same frame. + // The first release the context but the next one will still have this id. + if (cachedContext.refCount == 0) + { + Debug.Assert(cachedContext.renderingContext == null); // Context should already have been cleaned up. + return; + } + + cachedContext.refCount--; + if (cachedContext.refCount == 0) + cachedContext.Reset(); + } + + bool IsCachedContextValid(SkyUpdateContext skyContext) + { + if (skyContext.skySettings == null) // Sky set to None + return false; + + int id = skyContext.cachedSkyRenderingContextId; + // When the renderer changes, the cached context is no longer valid so we sometimes need to check that. + return id != -1 && (skyContext.skySettings.GetSkyRendererType() == m_CachedSkyContexts[id].type) && (m_CachedSkyContexts[id].hash != 0); + } + + int ComputeSkyHash(HDCamera camera, SkyUpdateContext skyContext, Light sunLight, SkyAmbientMode ambientMode, bool staticSky = false) + { + int sunHash = 0; + if (sunLight != null) + sunHash = GetSunLightHashCode(sunLight); + + // For planar reflections we want to use the parent position for hash. + Camera cameraForHash = camera.camera; + if (camera.camera.cameraType == CameraType.Reflection && camera.parentCamera != null) + { + cameraForHash = camera.parentCamera; + } + + int skyHash = sunHash * 23 + skyContext.skySettings.GetHashCode(cameraForHash); + skyHash = skyHash * 23 + (staticSky ? 1 : 0); + skyHash = skyHash * 23 + (ambientMode == SkyAmbientMode.Static ? 1 : 0); + return skyHash; + } + + public void RequestEnvironmentUpdate() + { + m_UpdateRequired = true; + } + + internal void RequestStaticEnvironmentUpdate() + { + m_StaticSkyUpdateRequired = true; + m_RequireWaitForAsyncReadBackRequest = true; + } + + public void UpdateEnvironment( HDCamera hdCamera, + ScriptableRenderContext renderContext, + SkyUpdateContext skyContext, + Light sunLight, + bool updateRequired, + bool updateAmbientProbe, + bool staticSky, + SkyAmbientMode ambientMode, + int frameIndex, + CommandBuffer cmd) + { + if (skyContext.IsValid()) + { + skyContext.currentUpdateTime += Time.deltaTime; // Consider using HDRenderPipeline.GetTime(). + + m_BuiltinParameters.hdCamera = hdCamera; + m_BuiltinParameters.commandBuffer = cmd; + m_BuiltinParameters.sunLight = sunLight; + m_BuiltinParameters.pixelCoordToViewDirMatrix = hdCamera.mainViewConstants.pixelCoordToViewDirWS; + Vector3 worldSpaceCameraPos = hdCamera.mainViewConstants.worldSpaceCameraPos; + // For planar reflections we use the parent camera position for all the runtime computations. + // This is to avoid cases in which the probe camera is below ground and the parent is not, leading to + // in case of PBR sky to a black sky. All other parameters are left as is. + // This can introduce inaccuracies, but they should be acceptable if the distance parent camera - probe camera is + // small. + if (hdCamera.camera.cameraType == CameraType.Reflection && hdCamera.parentCamera != null) + { + worldSpaceCameraPos = hdCamera.parentCamera.transform.position; + } + m_BuiltinParameters.worldSpaceCameraPos = worldSpaceCameraPos; + m_BuiltinParameters.viewMatrix = hdCamera.mainViewConstants.viewMatrix; + m_BuiltinParameters.screenSize = m_CubemapScreenSize; + m_BuiltinParameters.debugSettings = null; // We don't want any debug when updating the environment. + m_BuiltinParameters.frameIndex = frameIndex; + m_BuiltinParameters.skySettings = skyContext.skySettings; + + int skyHash = ComputeSkyHash(hdCamera, skyContext, sunLight, ambientMode, staticSky); + bool forceUpdate = updateRequired; + + // Acquire the rendering context, if the context was invalid or the hash has changed, this will request for an update. + forceUpdate |= AcquireSkyRenderingContext(skyContext, skyHash, staticSky ? "SkyboxCubemap_Static" : "SkyboxCubemap", !staticSky); + + ref CachedSkyContext cachedContext = ref m_CachedSkyContexts[skyContext.cachedSkyRenderingContextId]; + var renderingContext = cachedContext.renderingContext; + + if (IsCachedContextValid(skyContext)) + forceUpdate |= skyContext.skyRenderer.DoUpdate(m_BuiltinParameters); + + if (forceUpdate || + (skyContext.skySettings.updateMode.value == EnvironmentUpdateMode.OnChanged && skyHash != skyContext.skyParametersHash) || + (skyContext.skySettings.updateMode.value == EnvironmentUpdateMode.Realtime && skyContext.currentUpdateTime > skyContext.skySettings.updatePeriod.value)) + { + using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.UpdateSkyEnvironment))) + { + RenderSkyToCubemap(skyContext); + + if (updateAmbientProbe) + { + using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.UpdateSkyAmbientProbe))) + { + cmd.SetComputeBufferParam(m_ComputeAmbientProbeCS, m_ComputeAmbientProbeKernel, m_AmbientProbeOutputBufferParam, renderingContext.ambientProbeResult); + cmd.SetComputeTextureParam(m_ComputeAmbientProbeCS, m_ComputeAmbientProbeKernel, m_AmbientProbeInputCubemap, renderingContext.skyboxCubemapRT); + cmd.DispatchCompute(m_ComputeAmbientProbeCS, m_ComputeAmbientProbeKernel, 1, 1, 1); + cmd.RequestAsyncReadback(renderingContext.ambientProbeResult, renderingContext.OnComputeAmbientProbeDone); + + // When the profiler is enabled, we don't want to submit the render context because + // it will break all the profiling sample Begin() calls issued previously, which leads + // to profiling sample mismatch errors in the console. + if (!UnityEngine.Profiling.Profiler.enabled) + { + // In case we are the first frame after a domain reload, we need to wait for async readback request to complete + // otherwise ambient probe isn't correct for one frame. + if (m_RequireWaitForAsyncReadBackRequest) + { + cmd.WaitAllAsyncReadbackRequests(); + renderContext.ExecuteCommandBuffer(cmd); + CommandBufferPool.Release(cmd); + renderContext.Submit(); + cmd = CommandBufferPool.Get(); + m_RequireWaitForAsyncReadBackRequest = false; + } + } + } + } + + if (renderingContext.supportsConvolution) + { + RenderCubemapGGXConvolution(skyContext); + } + + skyContext.skyParametersHash = skyHash; + skyContext.currentUpdateTime = 0.0f; + +#if UNITY_EDITOR + // In the editor when we change the sky we want to make the GI dirty so when baking again the new sky is taken into account. + // Changing the hash of the rendertarget allow to say that GI is dirty + renderingContext.skyboxCubemapRT.rt.imageContentsHash = new Hash128((uint)skyContext.skySettings.GetHashCode(hdCamera.camera), 0, 0, 0); +#endif + } + } + } + else + { + if (skyContext.cachedSkyRenderingContextId != -1) + { + ReleaseCachedContext(skyContext.cachedSkyRenderingContextId); + skyContext.cachedSkyRenderingContextId = -1; + } + } + } + + public void UpdateEnvironment(HDCamera hdCamera, ScriptableRenderContext renderContext, Light sunLight, int frameIndex, CommandBuffer cmd) + { + SkyAmbientMode ambientMode = hdCamera.volumeStack.GetComponent().skyAmbientMode.value; + + UpdateEnvironment(hdCamera, renderContext, hdCamera.lightingSky, sunLight, m_UpdateRequired, ambientMode == SkyAmbientMode.Dynamic, false, ambientMode, frameIndex, cmd); + + // Preview camera will have a different sun, therefore the hash for the static lighting sky will change and force a recomputation + // because we only maintain one static sky. Since we don't care that the static lighting may be a bit different in the preview we never recompute + // and we use the one from the main camera. + bool forceStaticUpdate = false; + StaticLightingSky staticLightingSky = GetStaticLightingSky(); +#if UNITY_EDITOR + // In the editor, we might need the static sky ready for baking lightmaps/lightprobes regardless of the current ambient mode so we force it to update in this case if it's not been computed yet.. +<<<<<<< HEAD + // We don't test if the hash of the static sky has changed here because it depends on the sun direction and in the case of LookDev, sun will be different from the main rendering so it will induce improper recomputation. + forceStaticUpdate = staticLightingSky != null && m_StaticLightingSky.skyParametersHash == -1; ; +======= + // We always force an update of the static sky when we're in scene view mode. Previous behaviour was to prevent forced updates if the hash of the static sky was non-null, but this was preventing + // the lightmapper from updating in response to changes in environment. See GFXGI-237 for a better description of this issue. + + forceStaticUpdate = hdCamera.camera.cameraType == CameraType.SceneView; +>>>>>>> 03de1f2d54a... GFXGI-237: Force update for static skies when camera type is set to SceneView (#1570) +#endif + if ((ambientMode == SkyAmbientMode.Static || forceStaticUpdate) && hdCamera.camera.cameraType != CameraType.Preview) + { + m_StaticLightingSky.skySettings = staticLightingSky != null ? staticLightingSky.skySettings : null; + UpdateEnvironment(hdCamera, renderContext, m_StaticLightingSky, sunLight, m_StaticSkyUpdateRequired, true, true, SkyAmbientMode.Static, frameIndex, cmd); + m_StaticSkyUpdateRequired = false; + } + + m_UpdateRequired = false; + + var reflectionTexture = GetReflectionTexture(hdCamera.lightingSky); + cmd.SetGlobalTexture(HDShaderIDs._SkyTexture, reflectionTexture); + + if (IsLightingSkyValid(hdCamera)) + { + cmd.SetGlobalInt(HDShaderIDs._EnvLightSkyEnabled, 1); + } + else + { + cmd.SetGlobalInt(HDShaderIDs._EnvLightSkyEnabled, 0); + } + } + + internal void UpdateBuiltinParameters(SkyUpdateContext skyContext, HDCamera hdCamera, Light sunLight, RTHandle colorBuffer, RTHandle depthBuffer, DebugDisplaySettings debugSettings, int frameIndex, CommandBuffer cmd) + { + m_BuiltinParameters.hdCamera = hdCamera; + m_BuiltinParameters.commandBuffer = cmd; + m_BuiltinParameters.sunLight = sunLight; + m_BuiltinParameters.pixelCoordToViewDirMatrix = hdCamera.mainViewConstants.pixelCoordToViewDirWS; + m_BuiltinParameters.worldSpaceCameraPos = hdCamera.mainViewConstants.worldSpaceCameraPos; + m_BuiltinParameters.viewMatrix = hdCamera.mainViewConstants.viewMatrix; + m_BuiltinParameters.screenSize = hdCamera.screenSize; + m_BuiltinParameters.colorBuffer = colorBuffer; + m_BuiltinParameters.depthBuffer = depthBuffer; + m_BuiltinParameters.debugSettings = debugSettings; + m_BuiltinParameters.frameIndex = frameIndex; + m_BuiltinParameters.skySettings = skyContext.skySettings; + } + + public void PreRenderSky(HDCamera hdCamera, Light sunLight, RTHandle colorBuffer, RTHandle normalBuffer, RTHandle depthBuffer, DebugDisplaySettings debugSettings, int frameIndex, CommandBuffer cmd) + { + var skyContext = hdCamera.visualSky; + if (skyContext.IsValid()) + { + UpdateBuiltinParameters(skyContext, + hdCamera, + sunLight, + colorBuffer, + depthBuffer, + debugSettings, + frameIndex, + cmd); + + SkyAmbientMode ambientMode = hdCamera.volumeStack.GetComponent().skyAmbientMode.value; + int skyHash = ComputeSkyHash(hdCamera, skyContext, sunLight, ambientMode); + AcquireSkyRenderingContext(skyContext, skyHash); + skyContext.skyRenderer.DoUpdate(m_BuiltinParameters); + if (depthBuffer != BuiltinSkyParameters.nullRT && normalBuffer != BuiltinSkyParameters.nullRT) + { + CoreUtils.SetRenderTarget(cmd, normalBuffer, depthBuffer); + } + else if (depthBuffer != BuiltinSkyParameters.nullRT) + { + CoreUtils.SetRenderTarget(cmd, depthBuffer); + } + skyContext.skyRenderer.PreRenderSky(m_BuiltinParameters, false, hdCamera.camera.cameraType != CameraType.Reflection || skyContext.skySettings.includeSunInBaking.value); + } + } + + public void RenderSky(HDCamera hdCamera, Light sunLight, RTHandle colorBuffer, RTHandle depthBuffer, DebugDisplaySettings debugSettings, int frameIndex, CommandBuffer cmd) + { + var skyContext = hdCamera.visualSky; + if (skyContext.IsValid() && hdCamera.clearColorMode == HDAdditionalCameraData.ClearColorMode.Sky) + { + using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.RenderSky))) + { + UpdateBuiltinParameters(skyContext, + hdCamera, + sunLight, + colorBuffer, + depthBuffer, + debugSettings, + frameIndex, + cmd); + + SkyAmbientMode ambientMode = hdCamera.volumeStack.GetComponent().skyAmbientMode.value; + int skyHash = ComputeSkyHash(hdCamera, skyContext, sunLight, ambientMode); + AcquireSkyRenderingContext(skyContext, skyHash); + + skyContext.skyRenderer.DoUpdate(m_BuiltinParameters); + + if (depthBuffer == BuiltinSkyParameters.nullRT) + { + CoreUtils.SetRenderTarget(cmd, colorBuffer); + } + else + { + CoreUtils.SetRenderTarget(cmd, colorBuffer, depthBuffer); + } + + // If the luxmeter is enabled, we don't render the sky + if (debugSettings.data.lightingDebugSettings.debugLightingMode != DebugLightingMode.LuxMeter) + { + // When rendering the visual sky for reflection probes, we need to remove the sun disk if skySettings.includeSunInBaking is false. + skyContext.skyRenderer.RenderSky(m_BuiltinParameters, false, hdCamera.camera.cameraType != CameraType.Reflection || skyContext.skySettings.includeSunInBaking.value); + } + } + } + } + + public void RenderOpaqueAtmosphericScattering(CommandBuffer cmd, HDCamera hdCamera, + RTHandle colorBuffer, + RTHandle volumetricLighting, + RTHandle intermediateBuffer, + RTHandle depthBuffer, + Matrix4x4 pixelCoordToViewDirWS, bool isMSAA) + { + using (new ProfilingScope(m_BuiltinParameters.commandBuffer, ProfilingSampler.Get(HDProfileId.OpaqueAtmosphericScattering))) + { + m_OpaqueAtmScatteringBlock.SetMatrix(HDShaderIDs._PixelCoordToViewDirWS, pixelCoordToViewDirWS); + if (isMSAA) + m_OpaqueAtmScatteringBlock.SetTexture(HDShaderIDs._ColorTextureMS, colorBuffer); + else + m_OpaqueAtmScatteringBlock.SetTexture(HDShaderIDs._ColorTexture, colorBuffer); + // The texture can be null when volumetrics are disabled. + if (volumetricLighting != null) + m_OpaqueAtmScatteringBlock.SetTexture(HDShaderIDs._VBufferLighting, volumetricLighting); + + if (Fog.IsPBRFogEnabled(hdCamera)) + { + // Color -> Intermediate. + HDUtils.DrawFullScreen(cmd, m_OpaqueAtmScatteringMaterial, intermediateBuffer, depthBuffer, m_OpaqueAtmScatteringBlock, isMSAA ? 3 : 2); + // Intermediate -> Color. + // Note: Blit does not support MSAA (and is probably slower). + cmd.CopyTexture(intermediateBuffer, colorBuffer); + } + else + { + HDUtils.DrawFullScreen(cmd, m_OpaqueAtmScatteringMaterial, colorBuffer, depthBuffer, m_OpaqueAtmScatteringBlock, isMSAA ? 1 : 0); + } + } + } + + static public StaticLightingSky GetStaticLightingSky() + { + if (m_StaticLightingSkies.Count == 0) + return null; + else + return m_StaticLightingSkies[m_StaticLightingSkies.Count - 1]; + } + + static public void RegisterStaticLightingSky(StaticLightingSky staticLightingSky) + { + if (!m_StaticLightingSkies.Contains(staticLightingSky)) + { + if (m_StaticLightingSkies.Count != 0) + { + Debug.LogWarning("One Static Lighting Sky component was already set for baking, only the latest one will be used."); + } + + if (staticLightingSky.staticLightingSkyUniqueID == (int)SkyType.Procedural && !skyTypesDict.TryGetValue((int)SkyType.Procedural, out var dummy)) + { + Debug.LogError("You are using the deprecated Procedural Sky for static lighting in your Scene. You can still use it but, to do so, you must install it separately. To do this, open the Package Manager window and import the 'Procedural Sky' sample from the HDRP package page, then close and re-open your project without saving."); + return; + } + + m_StaticLightingSkies.Add(staticLightingSky); + } + } + + static public void UnRegisterStaticLightingSky(StaticLightingSky staticLightingSky) + { + m_StaticLightingSkies.Remove(staticLightingSky); + } + + public Texture2D ExportSkyToTexture(Camera camera) + { + var hdCamera = HDCamera.GetOrCreate(camera); + + if (!hdCamera.visualSky.IsValid() || !IsCachedContextValid(hdCamera.visualSky)) + { + Debug.LogError("Cannot export sky to a texture, no valid Sky is setup (Also make sure the game view has been rendered at least once)."); + return null; + } + + ref var cachedContext = ref m_CachedSkyContexts[hdCamera.visualSky.cachedSkyRenderingContextId]; + RenderTexture skyCubemap = cachedContext.renderingContext.skyboxCubemapRT; + + int resolution = skyCubemap.width; + + var tempRT = new RenderTexture(resolution * 6, resolution, 0, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear) + { + dimension = TextureDimension.Tex2D, + useMipMap = false, + autoGenerateMips = false, + filterMode = FilterMode.Trilinear + }; + tempRT.Create(); + + var temp = new Texture2D(resolution * 6, resolution, TextureFormat.RGBAFloat, false); + var result = new Texture2D(resolution * 6, resolution, TextureFormat.RGBAFloat, false); + + // Note: We need to invert in Y the cubemap faces because the current sky cubemap is inverted (because it's a RT) + // So to invert it again so that it's a proper cubemap image we need to do it in several steps because ReadPixels does not have scale parameters: + // - Convert the cubemap into a 2D texture + // - Blit and invert it to a temporary target. + // - Read this target again into the result texture. + int offset = 0; + for (int i = 0; i < 6; ++i) + { + UnityEngine.Graphics.SetRenderTarget(skyCubemap, 0, (CubemapFace)i); + temp.ReadPixels(new Rect(0, 0, resolution, resolution), offset, 0); + temp.Apply(); + offset += resolution; + } + + // Flip texture. + UnityEngine.Graphics.Blit(temp, tempRT, new Vector2(1.0f, -1.0f), new Vector2(0.0f, 0.0f)); + + result.ReadPixels(new Rect(0, 0, resolution * 6, resolution), 0, 0); + result.Apply(); + + UnityEngine.Graphics.SetRenderTarget(null); + CoreUtils.Destroy(temp); + CoreUtils.Destroy(tempRT); + + return result; + } + +#if UNITY_EDITOR + void OnBakeStarted() + { + var hdrp = HDRenderPipeline.defaultAsset; + if (hdrp == null) + return; + + // Happens sometime in the tests. + if (m_StandardSkyboxMaterial == null) + m_StandardSkyboxMaterial = CoreUtils.CreateEngineMaterial(hdrp.renderPipelineResources.shaders.skyboxCubemapPS); + + // At the start of baking we need to update the GI system with the static lighting sky in order for lightmaps and probes to be baked with it. + var staticLightingSky = GetStaticLightingSky(); + if (m_StaticLightingSky.skySettings != null && IsCachedContextValid(m_StaticLightingSky)) + { + var renderingContext = m_CachedSkyContexts[m_StaticLightingSky.cachedSkyRenderingContextId].renderingContext; + m_StandardSkyboxMaterial.SetTexture("_Tex", m_StaticLightingSky.IsValid() ? (Texture)renderingContext.skyboxCubemapRT : CoreUtils.blackCubeTexture); + } + else + { + m_StandardSkyboxMaterial.SetTexture("_Tex", CoreUtils.blackCubeTexture); + } + + RenderSettings.skybox = m_StandardSkyboxMaterial; // Setup this material as the default to be use in RenderSettings + RenderSettings.ambientIntensity = 1.0f; + RenderSettings.ambientMode = AmbientMode.Skybox; // Force skybox for our HDRI + RenderSettings.reflectionIntensity = 1.0f; + RenderSettings.customReflection = null; + + DynamicGI.UpdateEnvironment(); + } +#endif + } +} diff --git a/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeCapturePositionSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeCapturePositionSettings.cs index a0701b82a25..b2d3a2c24e8 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeCapturePositionSettings.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeCapturePositionSettings.cs @@ -160,6 +160,15 @@ static ProbeCapturePositionSettings ComputeFrom( var result = new ProbeCapturePositionSettings(); var proxyToWorld = probe.proxyToWorld; result.proxyPosition = proxyToWorld.GetColumn(3); + + // If reference position and proxy position is exactly the same, we end up in some degeneracies triggered + // by engine code when computing culling parameters. This is an extremely rare case, but can happen + // in editor when focusing on the planar probe. So if that happens, we offset them 0.1 mm apart. + if(Vector3.Distance(result.proxyPosition, referencePosition) < 1e-4f) + { + referencePosition += new Vector3(1e-4f, 1e-4f, 1e-4f); + } + result.proxyRotation = proxyToWorld.rotation; result.referencePosition = referencePosition; result.referenceRotation = referenceRotation;