diff --git a/com.unity.render-pipelines.core/Editor/FilterWindow.cs b/com.unity.render-pipelines.core/Editor/FilterWindow.cs index 514b15fd672..44f06c95e32 100644 --- a/com.unity.render-pipelines.core/Editor/FilterWindow.cs +++ b/com.unity.render-pipelines.core/Editor/FilterWindow.cs @@ -455,8 +455,11 @@ void HandleKeyboard() if (evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter) { - GoToChild(m_ActiveElement, true); - evt.Use(); + if (m_ActiveElement != null) + { + GoToChild(m_ActiveElement, true); + evt.Use(); + } } // Do these if we're not in search mode diff --git a/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs b/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs index fd1a725f16a..712beccaeed 100644 --- a/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs +++ b/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs @@ -216,24 +216,48 @@ event Action IViewDisplayer.OnUpdateRequested StyleSheet styleSheet = null; StyleSheet styleSheetLight = null; - void OnEnable() + void ReloadStyleSheets() { - //Stylesheet - // Try to load stylesheet. Timing can be odd while upgrading packages (case 1219692). - // In this case, it will be fixed in OnGUI. Though it can spawn error while reimporting assets. - // Waiting for filter on stylesheet (case 1228706) to remove last error. - if (styleSheet == null || styleSheet.Equals(null)) + if(styleSheet == null || styleSheet.Equals(null)) { styleSheet = AssetDatabase.LoadAssetAtPath(Style.k_uss); - if (styleSheet != null && !styleSheet.Equals(null)) - rootVisualElement.styleSheets.Add(styleSheet); + if(styleSheet == null || styleSheet.Equals(null)) + { + //Debug.LogWarning("[LookDev] Could not load Stylesheet."); + return; + } } - if (!EditorGUIUtility.isProSkin && styleSheetLight != null && !styleSheetLight.Equals(null)) + + if(!rootVisualElement.styleSheets.Contains(styleSheet)) + rootVisualElement.styleSheets.Add(styleSheet); + + //Additively load Light Skin + if(!EditorGUIUtility.isProSkin) { - styleSheetLight = AssetDatabase.LoadAssetAtPath(Style.k_uss_personal_overload); - if (styleSheetLight != null && !styleSheetLight.Equals(null)) + if(styleSheetLight == null || styleSheetLight.Equals(null)) + { + styleSheetLight = AssetDatabase.LoadAssetAtPath(Style.k_uss_personal_overload); + if(styleSheetLight == null || styleSheetLight.Equals(null)) + { + //Debug.LogWarning("[LookDev] Could not load Light skin."); + return; + } + } + + if(!rootVisualElement.styleSheets.Contains(styleSheetLight)) rootVisualElement.styleSheets.Add(styleSheetLight); } + } + + void OnEnable() + { + //Stylesheet + // Try to load stylesheet. Timing can be odd while upgrading packages (case 1219692). + // In this case, it will be fixed in OnGUI. Though it can spawn error while reimporting assets. + // Waiting for filter on stylesheet (case 1228706) to remove last error. + // On Editor Skin change, OnEnable is called and stylesheets need to be reloaded (case 1278802). + if(EditorApplication.isUpdating) + ReloadStyleSheets(); //Call the open function to configure LookDev // in case the window where open when last editor session finished. @@ -681,14 +705,11 @@ void OnGUI() // rootVisualElement.styleSheets.Add(styleSheetLight); //} } - else - { - //deal with missing style when domain reload... - if (!rootVisualElement.styleSheets.Contains(styleSheet)) - rootVisualElement.styleSheets.Add(styleSheet); - if (!EditorGUIUtility.isProSkin && !rootVisualElement.styleSheets.Contains(styleSheetLight)) - rootVisualElement.styleSheets.Add(styleSheetLight); - } + if(EditorApplication.isUpdating) + return; + + //deal with missing style on domain reload... + ReloadStyleSheets(); // [case 1245086] Guard in case the SRP asset is set to null (or to a not supported SRP) when the lookdev window is already open // Note: After an editor reload, we might get a null OnUpdateRequestedInternal and null SRP for a couple of frames, hence the check. diff --git a/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs b/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs index 9669c56a435..9d57249a1b0 100644 --- a/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs +++ b/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs @@ -119,8 +119,14 @@ void OnUndoRedoPerformed() // Dumb hack to make sure the serialized object is up to date on undo (else there'll be // a state mismatch when this class is used in a GameObject inspector). - m_SerializedObject.Update(); - m_SerializedObject.ApplyModifiedProperties(); + if (m_SerializedObject != null + && !m_SerializedObject.Equals(null) + && m_SerializedObject.targetObject != null + && !m_SerializedObject.targetObject.Equals(null)) + { + m_SerializedObject.Update(); + m_SerializedObject.ApplyModifiedProperties(); + } // Seems like there's an issue with the inspector not repainting after some undo events // This will take care of that diff --git a/com.unity.render-pipelines.core/Runtime/Volume/VolumeManager.cs b/com.unity.render-pipelines.core/Runtime/Volume/VolumeManager.cs index 4b81d97404e..ff1f4fdc7ff 100644 --- a/com.unity.render-pipelines.core/Runtime/Volume/VolumeManager.cs +++ b/com.unity.render-pipelines.core/Runtime/Volume/VolumeManager.cs @@ -124,7 +124,8 @@ public void Register(Volume volume, int layer) // Look for existing cached layer masks and add it there if needed foreach (var kvp in m_SortedVolumes) { - if ((kvp.Key & (1 << layer)) != 0) + // We add the volume to sorted lists only if the layer match and if it doesn't contain the volume already. + if ((kvp.Key & (1 << layer)) != 0 && !kvp.Value.Contains(volume)) kvp.Value.Add(volume); } diff --git a/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs b/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs index a687a86fb4d..4e97e2f1f92 100644 --- a/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs +++ b/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs @@ -75,6 +75,10 @@ public VolumeComponent Add(Type type, bool overrides = false) throw new InvalidOperationException("Component already exists in the volume"); var component = (VolumeComponent)CreateInstance(type); +#if UNITY_EDITOR + component.hideFlags = HideFlags.HideInInspector | HideFlags.HideInHierarchy; + component.name = type.Name; +#endif component.SetAllOverridesTo(overrides); components.Add(component); isDirty = true; diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 2b5d6b71e5b..904e8a978a9 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [8.3.1] - 2020-07-23 +### Added +- Added a warning when trying to bake with static lighting being in an invalid state. + ### Fixed - Fixed issue in Material Postprocess which may fail due to empty SubAsset. - Fixed a null ref exception when baking reflection probes. @@ -25,10 +28,33 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - 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 +- Fixed an issue that lead to corrupted refraction in some scenarios on xbox. +- Fixed issue when undoing a change in diffuse profile list after deleting the volume profile. +- Fixed a static lighting flickering issue caused by having an active planar probe in the scene while rendering inspector preview. +- Fixed an issue where even when set to OnDemand, the sky lighting would still be updated when changing sky parameters. +- Fixed SSS materials appearing black in matcap mode. +- Fixed rendering of custom passes in the Custom Pass Volume inspector +- Fixed issue with volume manager trying to access a null volume. +- Fixed issue with bloom showing a thin black line after rescaling window. +- Fixed an issue that caused a null reference when deleting camera component in a prefab. (case 1244430) +- Fixed nan in pbr sky +- Fixed Light skin not properly applied on the LookDev when switching from Dark Skin (case 1278802) +- Fixed Custom Post Processes affecting preview cameras. +- Fixed issue with box light not visible if range is below one and range attenuation is off. +- Fixed serialization issue with matcap scale intensity. +- Fixed error Maximum allowed thread group count is 65535 when resolution is very high. +- Fixed XR shadows culling +- Fixed volument component creation via script. +- Fixed shadow resolution settings level in the light explorer. +- Fixed issue when changing FoV with the physical camera fold-out closed. +- Fixed issue with exposure history being uninitialized on second frame. +- Fixed nan in reflection probe when volumetric fog filtering is enabled, causing the whole probe to be invalid. +- Fixed a null ref in the volume component list when there is no volume components in the project. ### Changed - Remove MSAA debug mode when renderpipeline asset has no MSAA - Reduced the number of global keyword used in deferredTile.shader +- Removed XRSystemTests. The GC verification is now done during playmode tests (case 1285012). ## [8.2.0] - 2020-07-08 diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Feature-Comparison.md b/com.unity.render-pipelines.high-definition/Documentation~/Feature-Comparison.md index ce0c7033b8d..7308402e414 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Feature-Comparison.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Feature-Comparison.md @@ -365,7 +365,7 @@ The tables that follow provide an overview of the **Features** that the High Def | **Feature** | **Built-in Render Pipeline** | **High Definition Render Pipeline (HDRP)** | | ------------- | ------------------------ | ------------------------------- | -| AR Foundation | No | No | +| AR Foundation | Yes | No | ## Debug 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 77ad0b3375c..436d5f85672 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 @@ -90,19 +90,19 @@ Unity exposes up to four Material layers for you to use in your Layered Material | **Smoothness Remapping** | Use this min-max slider to remap the smoothness values from the **Mask Map** to the range you specify. Rather than [clamping](https://docs.unity3d.com/ScriptReference/Mathf.Clamp.html) values to the new range, Unity condenses the original range down to the new range uniformly.
This property only appears when you assign a **Mask Map**. | | **Ambient Occlusion Remapping** | Use this min-max slider to remap the ambient occlusion values from the **Mask Map** to the range you specify. Rather than [clamping](https://docs.unity3d.com/ScriptReference/Mathf.Clamp.html) values to the new range, Unity condenses the original range down to the new range uniformly.
This property only appears when you assign a **Mask Map**. | | **Mask Map** | Assign a [channel-packed Texture](Glossary.html#ChannelPacking) with the following Material maps in its RGBA channels.
• **Red**: Stores the metallic map.
• **Green**: Stores the ambient occlusion map.
• **Blue**: Stores the detail mask map.
• **Alpha**: Stores the smoothness map.
For more information on channel-packed Textures and the mask map, see [mask map](Mask-Map-and-Detail-Map.html#MaskMap). | -| **Normal Map Space** | Use this drop-down to select the type of Normal Map space that this Material uses.• **TangentSpace**: Defines the normal map in UV space; use this to tile a Texture on a Mesh. The normal map Texture must be BC7, BC5, or DXT5nm format.• **ObjectSpace**: Defines the normal maps in world space. Use this for planar-mapping objects like the terrain. The normal map must be an RGB Texture . | +| **Normal Map Space** | Use this drop-down to select the type of Normal Map space that this Material uses.
• **TangentSpace**: Defines the normal map in UV space; use this to tile a Texture on a Mesh. The normal map Texture must be BC7, BC5, or DXT5nm format.
• **ObjectSpace**: Defines the normal maps in world space. Use this for planar-mapping objects like the terrain. The normal map must be an RGB Texture . | | **Normal Map** | Assign a Texture that defines the normal map for this Material in tangent space. Use the slider to modulate the normal intensity between 0 and 8.
This property only appears when you select **TangentSpace** from the **Normal Map Space** drop-down. | | **Normal Map OS** | Assign a Texture that defines the object space normal map for this Material. Use the handle to modulate the normal intensity between 0 and 8.
This property only appears when you select **ObjectSpace** from the **Normal Map Space** drop-down. | | **Bent Normal Map** | Assign a Texture that defines the bent normal map for this Material in tangent space. HDRP uses bent normal maps to simulate more accurate ambient occlusion. Note: Bent normal maps only work with diffuse lighting.
This property only appears when you select **TangentSpace** from the **Normal Map Space** drop-down.. | | **Bent Normal Map OS** | Assign a Texture that defines the bent normal map for this Material in object space. HDRP uses bent normal maps to simulate more accurate ambient occlusion. Note: Bent normal maps only work with diffuse lighting.
This property only appears when you select **ObjectSpace** from the **Normal Map Space** drop-down. | | **Height Map** | Assign a Texture that defines the heightmap for this Material. Unity uses this map to blend this layer. | -| **- Parametrization** | Use the drop-down to select the parametrization method for the to use for the **Height Map**.•**Min/Max**: HDRP compares the **Min** and **Max** value to calculate the peak, trough, and base position of the heightmap. If the **Min** is -1 and the **Max** is 3, then the base is at the Texture value 0.25. This uses the full range of the heightmap.•**Amplitude**: Allows you to manually set the amplitude and base position of the heightmap. This uses the full range of the heightmap. | +| **- Parametrization** | Use the drop-down to select the parametrization method for the to use for the **Height Map**.
• **Min/Max**: HDRP compares the **Min** and **Max** value to calculate the peak, trough, and base position of the heightmap. If the **Min** is -1 and the **Max** is 3, then the base is at the Texture value 0.25. This uses the full range of the heightmap.
• **Amplitude**: Allows you to manually set the amplitude and base position of the heightmap. This uses the full range of the heightmap. In this mode, **Amplitude** sets the range of values and **Base** defines how far through the range the zero value (base) is. For example, if **Amplitude** is 100 and **Base** is 0.5 (the default value), the minimum value is -50 and the maximum value if 50. If you then set **Base** to 0, the minimum value becomes 0 and the maximum value becomes 100. | | **- Min** | Set the minimum value in the **Height Map**. | | **- Max** | Set the maximum value in the **Height Map**. | | **- Offset** | Set the offset that HDRP applies to the **Height Map**. | -| **- Amplitude** | Set the amplitude of the **Height Map**. | -| **- Base** | Use the slider to set the base for the **Height Map**. | -| **Base UV Mapping** | Use the drop-down to select the type of UV mapping that HDRP uses to map Textures to this Material’s surface.• Unity manages four UV channels for a vertex: **UV0**, **UV1**, **UV2**, and **UV3**.• **Planar:** A planar projection from top to bottom.• **Triplanar**: A planar projection in three directions:X-axis: Left to rightY-axis: Top to bottomZ-axis: Front to back Unity blends these three projections together to produce the final result. | +| **- Amplitude** | Set the amplitude of the **Height Map**. This is the range of values the height map represents. | +| **- Base** | Use the slider to set the base for the **Height Map**. This is the value of the level 0 in the height map. If you set this to 0.5 and set **Amplitude** to 100, the minimum value is -50 and the maximum value is 50. | +| **Base UV Mapping** | Use the drop-down to select the type of UV mapping that HDRP uses to map Textures to this Material’s surface.
• Unity manages four UV channels for a vertex: **UV0**, **UV1**, **UV2**, and **UV3**.
• **Planar:** A planar projection from top to bottom.
• **Triplanar**: A planar projection in three directions:X-axis: Left to rightY-axis: Top to bottomZ-axis: Front to back Unity blends these three projections together to produce the final result. | | **Tiling** | Set an **X** and **Y** UV tile rate for all of the Textures in the **Surface Inputs** section. HDRP uses the **X** and **Y** values to tile these Textures across the Material’s surface, in object space. | | **Offset** | Set an **X** and **Y** UV offset for all of the Textures in the **Surface Inputs** section. HDRP uses the **X** and **Y** values to offset these Textures across the Material’s surface, in object. | @@ -128,7 +128,7 @@ Unity exposes up to four Material layers for you to use in your Layered Material | **Emission UV Mapping** | Use the drop-down to select the type of UV mapping that HDRP uses for the **Emission Map**.• Unity manages four UV channels for a vertex: **UV0**, **UV1**, **UV2**, and **UV3**.• **Planar:** A planar projection from top to bottom.• **Triplanar**: A planar projection in three directions:X-axis: Left to rightY-axis: Top to bottomZ-axis: Front to back Unity blends these three projections together to produce the final result. | | **- Tiling** | Set an **X** and **Y** tile rate for the **Emission Map** UV. HDRP uses the **X** and **Y** values to tile the Texture assigned to the **Emission Map** across the Material’s surface, in object space. | | **- Offset** | Set an **X** and **Y** offset for the **Emission Map** UV. HDRP uses the **X** and **Y** values to offset the Texture assigned to the **Emission Map** 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:• [Nits](Physical-Light-Units.html#Nits)• [EV100](Physical-Light-Units.html#EV) | +| **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.md) to use for intensity:
• [Nits](Physical-Light-Units.md#Nits)
• [EV100](Physical-Light-Units.md#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** | Toggles whether emission affects global illumination. | 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 d5a4d5ea6e8..567ffdf9218 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 @@ -106,7 +106,7 @@ To make this section visible, disable **Earth Preset**. This sky type is a practical implementation of the method outlined in the paper [Precomputed Atmospheric Scattering](http://www-ljk.imag.fr/Publications/Basilic/com.lmc.publi.PUBLI_Article@11e7cdda2f7_f64b69/article.pdf) (Bruneton and Neyret, 2008). -This technique assumes that you always view the Scene from above the surface of the planet. This means that if you go below the planet's surface, the sky renders black. Where the surface of the planet is depends on whether you enable or disable **Spherical Mode**: +This technique assumes that you always view the Scene from above the surface of the planet. This means that if a camera goes below the planet's surface, the sky renders as it would do if the camera was at ground level. Where the surface of the planet is depends on whether you enable or disable **Spherical Mode**: * If you enable **Spherical Mode**, the **Planetary Radius** and **Planet Center Position** properties define where the surface is. In this mode, the surface is at the distance set in **Planetary Radius** away from the position set in **Planet Center Position**. * Otherwise, the **Sea Level** property defines where the surface is. In this mode, the surface stretches out infinitely on the xz plane and **Sea Level** sets its world space height. diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Render-Pipeline-Debug-Window.md b/com.unity.render-pipelines.high-definition/Documentation~/Render-Pipeline-Debug-Window.md index 1bb071c12ee..ffc81c243f6 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Render-Pipeline-Debug-Window.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Render-Pipeline-Debug-Window.md @@ -140,7 +140,7 @@ The **Rendering** panel has tools that you can use to visualize various HDRP ren | **Debug Option** | **Description** | | ----------------------------- | ------------------------------------------------------------ | -| **Fullscreen Debug Mode** | Use the drop-down to select a rendering mode to display as an overlay on the screen.
• **Motion Vectors**: Select this option to display motion vectors.
• **NaN Tracker**: Select this option to display an overlay that highlights [NaN]() values. | +| **Fullscreen Debug Mode** | Use the drop-down to select a rendering mode to display as an overlay on the screen.
• **Motion Vectors**: Select this option to display motion vectors. Note that object motion vectors are not visible in the Scene view.
• **NaN Tracker**: Select this option to display an overlay that highlights [NaN]() values. | | **MipMaps** | Use the drop-down to select a mipmap streaming property to debug.
• **None**: Select this option to disable this debug feature.
• **MipRatio**: Select this option to display a heat map of pixel to texel ratio. A blue tint represents areas with too little Texture detail (the Texture is too small). A bed tint represents areas with too much Texture detail (the Texture is too large for the screen area). If the debugger shows the original colour for a pixel, this means that the level of detail is just right.
• **MipCount**: Select this option to display mip count as grayscale from black to white as the number of mips increases (for up to 14 mips, or 16K size). Red inidates Textures with more than 14 mips. Magenta indicates Textures with 0 mips or that the Shader does not support mip count.
• **MipCountReduction**: Select this option to display the difference between the current mip count and the original mip count as a green scale. A brighter green represents a larger reduction (that mip streaming saves more Texture memory). Magenta means that the debugger does not know the original mip count.
• **StreamingMipBudget**: Select this option to display the mip status due to streaming budget. Green means that streaming Textures saves some memory. Red means that mip levels are lower than is optimal, due to full Texture memory budget. White means that streaming Textures saves no memory.
• **StreamingMip**: Select this option to display the same information as **StreamingMipBudget**, but to apply the colors to the original Textures. | | **- Terrain Texture** | Use the drop-down to select the terrain Texture to debug the mipmap for. This property only appears when you select an option other than **None** from the **MipMaps** drop-down. | | **Color Picker - Debug Mode** | Use the drop-down to select the format of the color picker display. | diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightExplorerExtension.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightExplorerExtension.cs index 6cb1a7b02bf..c3b586f813d 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightExplorerExtension.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightExplorerExtension.cs @@ -426,7 +426,7 @@ protected virtual LightingExplorerTableColumn[] GetHDLightColumns() var shadowResolution = lightData.shadowResolution; EditorGUI.BeginChangeCheck(); - var (level, useOverride) = SerializedScalableSettingValueUI.LevelFieldGUI(r, GUIContent.none, ScalableSettingSchema.GetSchemaOrNull(ScalableSettingSchemaId.With3Levels), shadowResolution.level, shadowResolution.useOverride); + var (level, useOverride) = SerializedScalableSettingValueUI.LevelFieldGUI(r, GUIContent.none, ScalableSettingSchema.GetSchemaOrNull(ScalableSettingSchemaId.With4Levels), shadowResolution.level, shadowResolution.useOverride); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(lightData, "Changed contact shadow resolution"); diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/DecalSurfaceInputsUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/DecalSurfaceInputsUIBlock.cs index 81ae763ee74..adc0a08b3ca 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/DecalSurfaceInputsUIBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/DecalSurfaceInputsUIBlock.cs @@ -34,7 +34,7 @@ public class Styles public static GUIContent useEmissionIntensityText = new GUIContent("Use Emission Intensity", "When enabled, this Material separates emission color and intensity. This makes the Emission Map into an LDR color and exposes the Emission Intensity property."); public static GUIContent emissionMapText = new GUIContent("Emission Map", "Specifies a map (RGB) that the Material uses for emission."); public static GUIContent emissiveIntensityText = new GUIContent("Emission Intensity", "Sets the overall strength of the emission effect."); - public static GUIContent emissiveExposureWeightText = new GUIContent("Exposure weight", "Control the percentage of emission to expose."); + public static GUIContent emissiveExposureWeightText = new GUIContent("Exposure weight", "Controls how the camera exposure influences the perceived intensity of the emissivity. A weight of 0 means that the emissive intensity is calculated ignoring the exposure; increasing this weight progressively increases the influence of exposure on the final emissive value."); public static GUIContent[] maskMapText = { diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/EmissionUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/EmissionUIBlock.cs index 34a9c22eff4..83125173b46 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/EmissionUIBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/EmissionUIBlock.cs @@ -40,7 +40,7 @@ public class Styles public static GUIContent useEmissiveIntensityText = new GUIContent("Use Emission Intensity", "Specifies whether to use to a HDR color or a LDR color with a separate multiplier."); public static GUIContent emissiveIntensityText = new GUIContent("Emission Intensity", ""); public static GUIContent emissiveIntensityFromHDRColorText = new GUIContent("The emission intensity is from the HDR color picker in luminance", ""); - public static GUIContent emissiveExposureWeightText = new GUIContent("Exposure weight", "Control the percentage of emission to expose."); + public static GUIContent emissiveExposureWeightText = new GUIContent("Exposure weight", "Controls how the camera exposure influences the perceived intensity of the emissivity. A weight of 0 means that the emissive intensity is calculated ignoring the exposure; increasing this weight progressively increases the influence of exposure on the final emissive value."); public static GUIContent UVEmissiveMappingText = new GUIContent("Emission UV mapping", ""); public static GUIContent texWorldScaleText = new GUIContent("World Scale", "Sets the tiling factor HDRP applies to Planar/Trilinear mapping."); diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraEditor.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraEditor.cs index c342379b064..f21056c5419 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraEditor.cs @@ -77,15 +77,32 @@ public void RemoveComponent(Camera camera, IEnumerable dependencies) return; } - Undo.SetCurrentGroupName("Remove HD Camera"); - var additionalCameraData = camera.GetComponent(); - if (additionalCameraData) + var isAssetEditing = EditorUtility.IsPersistent(camera); + try { - Undo.DestroyObjectImmediate(additionalCameraData); + if (isAssetEditing) + { + AssetDatabase.StartAssetEditing(); + } + + Undo.SetCurrentGroupName("Remove HD Camera"); + var additionalCameraData = camera.GetComponent(); + if (additionalCameraData != null) + { + Undo.DestroyObjectImmediate(additionalCameraData); + } + + Undo.DestroyObjectImmediate(camera); + } + finally + { + if (isAssetEditing) + { + AssetDatabase.StopAssetEditing(); + } } - Undo.DestroyObjectImmediate(camera); } - + [MenuItem("CONTEXT/Camera/Reset", false, 0)] static void ResetCamera(MenuCommand menuCommand) { diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs index f90ab8abf7b..ffc25abeedb 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs @@ -283,6 +283,18 @@ static void Drawer_Projection(SerializedHDCamera p, Editor owner) ? s_FovLastValue : Camera.HorizontalToVerticalFieldOfView(s_FovLastValue, (p.serializedObject.targetObjects[0] as Camera).aspect); } + else if (s_FovChanged && isPhysicalCamera && !p.projectionMatrixMode.hasMultipleDifferentValues) + { + // If we have a physical camera, we should also update the focal length here, because the + // Drawer_PhysicalCamera will not be executed if the physical camera fold-out is closed + cam.verticalFOV.floatValue = fovAxisVertical + ? s_FovLastValue + : Camera.HorizontalToVerticalFieldOfView(s_FovLastValue, (p.serializedObject.targetObjects[0] as Camera).aspect); + + float sensorLength = cam.fovAxisMode.intValue == 0 ? cam.sensorSize.vector2Value.y : cam.sensorSize.vector2Value.x; + float focalLengthVal = Camera.FieldOfViewToFocalLength(s_FovLastValue, sensorLength); + cam.focalLength.floatValue = EditorGUILayout.FloatField(focalLengthContent, focalLengthVal); + } EditorGUILayout.Space(); } diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/CustomPassDrawer.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/CustomPassDrawer.cs index 4921eb510ce..3ffc0e3db43 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/CustomPassDrawer.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/CustomPassDrawer.cs @@ -196,8 +196,8 @@ protected virtual void DoPassGUI(SerializedProperty customPass, Rect rect) { foreach (var prop in m_CustomPassUserProperties) { - EditorGUI.PropertyField(rect, prop); - rect.y += Styles.defaultLineSpace; + EditorGUI.PropertyField(rect, prop, true); + rect.y += EditorGUI.GetPropertyHeight(prop); } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Core/Textures/TextureCache2D.cs b/com.unity.render-pipelines.high-definition/Runtime/Core/Textures/TextureCache2D.cs index 2f4d19fa707..441336adaf7 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Core/Textures/TextureCache2D.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Core/Textures/TextureCache2D.cs @@ -77,7 +77,7 @@ public bool AllocTextureArray(int numTextures, int width, int height, GraphicsFo var res = AllocTextureArray(numTextures); m_NumMipLevels = GetNumMips(width, height); - var desc = new RenderTextureDescriptor(width, width, format, 0) + var desc = new RenderTextureDescriptor(width, height, format, 0) { // autoGenerateMips is true by default dimension = TextureDimension.Tex2DArray, diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/ClearLightLists.compute b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/ClearLightLists.compute index 32274fae94b..941732df6da 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/ClearLightLists.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/ClearLightLists.compute @@ -1,11 +1,14 @@ #pragma kernel ClearList RWStructuredBuffer _LightListToClear; -int _LightListEntries; +int2 _LightListEntriesAndOffset; + +#define _LightListEntries (uint)_LightListEntriesAndOffset.x +#define _LightListOffset (uint)_LightListEntriesAndOffset.y [numthreads(64, 1, 1)] void ClearList(uint3 id : SV_DispatchThreadID) { - if (id.x < (uint)_LightListEntries) - _LightListToClear[id.x] = 0; + if ((id.x + _LightListOffset) < (uint)_LightListEntries) + _LightListToClear[id.x + _LightListOffset] = 0; } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs index 1ca6843ed51..922000ad36b 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs @@ -3124,9 +3124,27 @@ void ClearLightList(HDCamera camera, CommandBuffer cmd, ComputeBuffer bufferToCl var kernel = cs.FindKernel("ClearList"); cmd.SetComputeBufferParam(cs, kernel, HDShaderIDs._LightListToClear, bufferToClear); - cmd.SetComputeIntParam(cs, HDShaderIDs._LightListEntries, bufferToClear.count); + Vector2 countAndOffset = new Vector2Int(bufferToClear.count, 0); int groupSize = 64; + int totalNumberOfGroupsNeeded = (bufferToClear.count + groupSize - 1) / groupSize; + + const int maxAllowedGroups = 65535; + // On higher resolutions we might end up with more than 65535 group which is not allowed, so we need to to have multiple dispatches. + int i = 0; + while (totalNumberOfGroupsNeeded > 0) + { + countAndOffset.y = maxAllowedGroups * i; + cmd.SetComputeVectorParam(cs, HDShaderIDs._LightListEntriesAndOffset, countAndOffset); + + int currGroupCount = Math.Min(maxAllowedGroups, totalNumberOfGroupsNeeded); + + cmd.DispatchCompute(cs, kernel, currGroupCount, 1, 1); + + totalNumberOfGroupsNeeded -= currGroupCount; + i++; + } + cmd.DispatchCompute(cs, kernel, (bufferToClear.count + groupSize - 1) / groupSize, 1, 1); } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/PunctualLightCommon.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/PunctualLightCommon.hlsl index 6a580a85cb4..f988198d2d2 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/PunctualLightCommon.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/PunctualLightCommon.hlsl @@ -27,16 +27,22 @@ void GetPunctualLightVectors(float3 positionWS, LightData light, out float3 L, o { L = -light.forward; + float dist = -dot(lightToSample, L); + float distSq = dist * dist; + distances.y = distSq; if (light.rangeAttenuationBias == 1.0) // Light uses range attenuation { - float dist = -dot(lightToSample, L); - float distSq = dist * dist; float distRcp = rcp(dist); - distances.xyz = float3(dist, distSq, distRcp); + distances.x = dist; + distances.z = distRcp; ModifyDistancesForFillLighting(distances, light.size.x); } else // Light is directionnal - distances.xyz = 1; // No distance or angle attenuation + { + // Note we maintain distances.y as otherwise the windowing function will give wrong results. + // There won't be attenuation as the light attenuation scale and biases are set such that attenuation is prevented. + distances.xz = 1; // No distance or angle attenuation + } } else { diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbe.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbe.cs index 145981a32b3..f55554c079d 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbe.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbe.cs @@ -437,8 +437,7 @@ internal void ForceRenderingNextUpdate() void UpdateProbeName() { - // TODO: ask if this is ok: - if (settings.type == ProbeSettings.ProbeType.PlanarProbe) + if (settings.type == ProbeSettings.ProbeType.ReflectionProbe) { for (int i = 0; i < 6; i++) probeName[i] = $"Reflection Probe RenderCamera ({name}: {(CubemapFace)i})"; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/VolumeProjection.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/VolumeProjection.hlsl index eec3ce341e8..44b7a285695 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/VolumeProjection.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/VolumeProjection.hlsl @@ -27,6 +27,9 @@ float IntersectSphereProxy(EnvLightData lightData, float3 dirPS, float3 position { float sphereOuterDistance = lightData.proxyExtents.x; float projectionDistance = IntersectRaySphereSimple(positionPS, dirPS, sphereOuterDistance); + projectionDistance = IsNaN(projectionDistance) ? -1.0f : projectionDistance; // Note that because we use IntersectRaySphereSimple, in case of a ill-set proxy, it could be that + // the determinant in the ray-sphere intersection code ends up negative, leading to a NaN. + // Rather than complicating the IntersectRaySphereSimple or switching to a more complex case, we cover that case this way. projectionDistance = max(projectionDistance, lightData.minProjectionDistance); // Setup projection to infinite if requested (mean no projection shape) return projectionDistance; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.compute b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.compute index 12e077504ca..642f5309e84 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.compute @@ -783,10 +783,15 @@ void FilterVolumetricLighting(uint3 dispatchThreadId : SV_DispatchThreadID, // If this is outside of the image, force the weight to 0 #ifdef VERTICAL_PASS - if (tapCoord.y < 0.0 || tapCoord.y >= _VBufferViewportSize.y) weight = 0; + if (tapCoord.y < 0.0 || tapCoord.y >= _VBufferViewportSize.y) #else - if (tapCoord.x < 0.0|| tapCoord.x >= _VBufferViewportSize.x) weight = 0; + if (tapCoord.x < 0.0 || tapCoord.x >= _VBufferViewportSize.x) #endif + { + // To avoid NaNs, we have to override this value + currentValue = 0.0f; + weight = 0.0f; + } // Accumulate the value and weight value += currentValue * weight; diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs index 9a13f6b81b3..528557fb54a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs @@ -136,12 +136,12 @@ private enum SMAAStage HDRenderPipeline m_HDInstance; - void FillEmptyExposureTexture() + static void SetExposureTextureToEmpty(RTHandle exposureTexture) { var tex = new Texture2D(1, 1, TextureFormat.RGHalf, false, true); tex.SetPixel(0, 0, new Color(1f, ColorUtils.ConvertExposureToEV100(1f), 0f, 0f)); tex.Apply(); - Graphics.Blit(tex, m_EmptyExposureTexture); + Graphics.Blit(tex, exposureTexture); CoreUtils.Destroy(tex); } @@ -218,7 +218,7 @@ public PostProcessSystem(HDRenderPipelineAsset hdAsset, RenderPipelineResources // TODO: Write a version that uses structured buffer instead of texture to do atomic as Metal doesn't support atomics on textures. m_MotionBlurSupportsScattering = m_MotionBlurSupportsScattering && (SystemInfo.graphicsDeviceType != GraphicsDeviceType.Metal); - FillEmptyExposureTexture(); + SetExposureTextureToEmpty(m_EmptyExposureTexture); // Initialize our target pool to ease RT management m_Pool = new TargetPool(); @@ -305,7 +305,7 @@ public void Cleanup() void CheckRenderTexturesValidity() { if (!m_EmptyExposureTexture.rt.IsCreated()) - FillEmptyExposureTexture(); + SetExposureTextureToEmpty(m_EmptyExposureTexture); HDUtils.CheckRTCreated(m_InternalLogLut.rt); HDUtils.CheckRTCreated(m_TempTexture1024.rt); @@ -436,24 +436,6 @@ void PoolSource(ref RTHandle src, RTHandle dst) if (m_PostProcessEnabled) { - // Guard bands (also known as "horrible hack") to avoid bleeding previous RTHandle - // content into smaller viewports with some effects like Bloom that rely on bilinear - // filtering and can't use clamp sampler and the likes - // Note: some platforms can't clear a partial render target so we directly draw black triangles - { - int w = camera.actualWidth; - int h = camera.actualHeight; - cmd.SetRenderTarget(source, 0, CubemapFace.Unknown, -1); - - if (w < source.rt.width || h < source.rt.height) - { - cmd.SetViewport(new Rect(w, 0, k_RTGuardBandSize, h)); - cmd.DrawProcedural(Matrix4x4.identity, m_ClearBlackMaterial, 0, MeshTopology.Triangles, 3, 1); - cmd.SetViewport(new Rect(0, h, w + k_RTGuardBandSize, k_RTGuardBandSize)); - cmd.DrawProcedural(Matrix4x4.identity, m_ClearBlackMaterial, 0, MeshTopology.Triangles, 3, 1); - } - } - // Optional NaN killer before post-processing kicks in bool stopNaNs = camera.stopNaNs && m_StopNaNFS; @@ -826,9 +808,11 @@ static void GrabExposureHistoryTextures(HDCamera camera, out RTHandle previous, RTHandle Allocator(string id, int frameIndex, RTHandleSystem rtHandleSystem) { // r: multiplier, g: EV100 - return rtHandleSystem.Alloc(1, 1, colorFormat: k_ExposureFormat, + var rt = rtHandleSystem.Alloc(1, 1, colorFormat: k_ExposureFormat, enableRandomWrite: true, name: $"Exposure Texture ({id}) {frameIndex}" ); + SetExposureTextureToEmpty(rt); + return rt; } // We rely on the RT history system that comes with HDCamera, but because it is swapped diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/BloomPrefilter.compute b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/BloomPrefilter.compute index 627a1294a87..d401631b5ca 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/BloomPrefilter.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/BloomPrefilter.compute @@ -67,7 +67,7 @@ void KMain(uint3 dispatchThreadId : SV_DispatchThreadID) float3 output = acc / wSum; // Guard bands - output *= all(dispatchThreadId.xy < uint2(_TexelSize.xy)); + output *= all(dispatchThreadId.xy <= uint2(_TexelSize.xy)); _OutputTexture[COORD_TEXTURE2D_X(posInputs.positionSS)] = output; } diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/BloomUpsample.compute b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/BloomUpsample.compute index 5cfe56c214b..c52cbe57eb9 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/BloomUpsample.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/BloomUpsample.compute @@ -29,8 +29,8 @@ void MAIN(uint3 dispatchThreadId : SV_DispatchThreadID) { UNITY_XR_ASSIGN_VIEW_INDEX(dispatchThreadId.z); PositionInputs posInputs = GetPositionInput(float2(dispatchThreadId.xy), _TexelSize.zw, uint2(GROUP_SIZE, GROUP_SIZE)); - float2 uv = ClampAndScaleUVForBilinear(posInputs.positionNDC, _TexelSize.zw) ; - float3 highRes = LOAD_TEXTURE2D_X(_InputHighTexture, posInputs.positionSS).xyz; + float2 uv = ClampAndScaleUV(posInputs.positionNDC, _BloomBicubicParams.zw, 1.0f); + float3 highRes = LOAD_TEXTURE2D_X(_InputHighTexture, clamp(posInputs.positionSS, 0, _TexelSize.xy - 1)).xyz; #if LOW_QUALITY float3 lowRes = SAMPLE_TEXTURE2D_X_LOD(_InputLowTexture, sampler_LinearClamp, uv, 0.0).xyz; @@ -42,7 +42,7 @@ void MAIN(uint3 dispatchThreadId : SV_DispatchThreadID) float3 output = lerp(highRes, lowRes, Scatter); // Guard bands - output *= all(dispatchThreadId.xy < uint2(_TexelSize.xy)); + output *= all(dispatchThreadId.xy <= uint2(_TexelSize.xy)); _OutputTexture[COORD_TEXTURE2D_X(dispatchThreadId.xy)] = output; } diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DepthOfFieldGather.compute b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DepthOfFieldGather.compute index 3a4f9e030fc..c248f8a52bc 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DepthOfFieldGather.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DepthOfFieldGather.compute @@ -101,13 +101,9 @@ void MAIN(uint3 dispatchThreadId : SV_DispatchThreadID) float mip = min(kMaxMips, (1.0 / (SampleCount - 1.5)) * samp0CoC * Radius); #endif - // Avoid bleeding with the RTHandle autosize system -#if FAR - // A bit more generous maxCoord because of trilinear being involved. - float texelsToClamp = 2.0f; -#else - float texelsToClamp = 1.0f; -#endif + uint mipCeiled = ceil(mip); + float texelsToClamp = (1u << mipCeiled) + 1; + float4 acc = 0.0; float nearWeightAcc = 0.0; float accAlpha = 0.0; 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 62dc8061a1e..db1231e5407 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 @@ -12,7 +12,9 @@ struct LookDevDataForHDRP public VisualEnvironment visualEnvironment; public HDRISky sky; public Volume volume; +#if UNITY_EDITOR public int currentVolumeProfileHash; +#endif } #if UNITY_EDITOR 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 10aa5616571..2fe899fd7c1 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -2750,6 +2750,10 @@ out ScriptableCullingParameters cullingParams if (hdCamera.xr.enabled) { cullingParams = hdCamera.xr.cullingParams; + + // Sync the FOV on the camera to match the projection from the XR device in order to cull shadows accurately + if (!camera.usePhysicalProperties) + camera.fieldOfView = Mathf.Rad2Deg * Mathf.Atan(1.0f / cullingParams.stereoProjectionMatrix.m11) * 2.0f; } else { diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs index d56b76aabaa..f624d8a3c78 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs @@ -175,7 +175,7 @@ static class HDShaderIDs public static readonly int g_vLayeredOffsetsBuffer = Shader.PropertyToID("g_vLayeredOffsetsBuffer"); public static readonly int _LightListToClear = Shader.PropertyToID("_LightListToClear"); - public static readonly int _LightListEntries = Shader.PropertyToID("_LightListEntries"); + public static readonly int _LightListEntriesAndOffset = Shader.PropertyToID("_LightListEntriesAndOffset"); public static readonly int _ViewTilesFlags = Shader.PropertyToID("_ViewTilesFlags"); public static readonly int _MousePixelCoord = Shader.PropertyToID("_MousePixelCoord"); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs index 5c007ed8c98..c0f3d44d951 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs @@ -696,10 +696,19 @@ internal static void Sanitize(ref FrameSettings sanitizedFrameSettings, Camera c sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.CustomPass] &= renderPipelineSettings.supportCustomPass; sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.CustomPass] &= camera.cameraType != CameraType.Preview; + sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.CustomPostProcess] &= camera.cameraType != CameraType.Preview; + // Deferred opaque are always using Fptl. Forward opaque can use Fptl or Cluster, transparent use cluster. // When MSAA is enabled we disable Fptl as it become expensive compare to cluster // In HD, MSAA is only supported for forward only rendering, no MSAA in deferred mode (for code complexity reasons) sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.FPTLForForwardOpaque] &= !msaa; + + // We disable reflection probes and planar reflections in regular preview rendering for two reasons. + // - Performance: Realtime reflection are 99% not necessary in previews + // - Static lighting consistency: When rendering a planar probe from a preview camera it may induce a recomputing of the static lighting + // but with the preview lights which are different from the ones in the scene and will change the result inducing flickering. + sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.ReflectionProbe] &= !preview; + sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.PlanarProbe] &= !preview; } /// Aggregation is default with override of the renderer then sanitized depending on supported features of hdrpasset. diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs index f58dc38c772..f30775f3d0e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs @@ -623,8 +623,9 @@ internal static bool IsSupportedBuildTarget(UnityEditor.BuildTarget buildTarget) buildTarget == UnityEditor.BuildTarget.WSAPlayer || buildTarget == UnityEditor.BuildTarget.XboxOne || buildTarget == UnityEditor.BuildTarget.PS4 || - buildTarget == UnityEditor.BuildTarget.iOS || - buildTarget == UnityEditor.BuildTarget.Switch); + // buildTarget == UnityEditor.BuildTarget.iOS || // IOS isn't supported + // buildTarget == UnityEditor.BuildTarget.Switch || // Switch isn't supported + buildTarget == UnityEditor.BuildTarget.CloudRendering); } internal static bool AreGraphicsAPIsSupported(UnityEditor.BuildTarget target, out GraphicsDeviceType unsupportedGraphicDevice) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.shader b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.shader index 299b583f8c1..841154f1d2d 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.shader @@ -147,7 +147,7 @@ Shader "Hidden/HDRP/Sky/PbrSky" float w = saturate(1 - r * rcp(light.flareSize)); color *= light.flareTint; - scale *= pow(w, light.flareFalloff); + scale *= SafePositivePow(w, light.flareFalloff); } radiance += color * scale; 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 42fe8b19026..3f6a79fa38c 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs @@ -727,6 +727,18 @@ public void UpdateEnvironment( HDCamera hdCamera, m_BuiltinParameters.frameIndex = frameIndex; m_BuiltinParameters.skySettings = skyContext.skySettings; + // When update is not requested and the context is already valid (ie: already computed at least once), + // we need to early out in two cases: + // - updateMode is "OnDemand" in which case we never update unless explicitly requested + // - updateMode is "Realtime" in which case we only update if the time threshold for realtime update is passed. + if (IsCachedContextValid(skyContext) && !updateRequired) + { + if (skyContext.skySettings.updateMode.value == EnvironmentUpdateMode.OnDemand) + return; + else if (skyContext.skySettings.updateMode.value == EnvironmentUpdateMode.Realtime && skyContext.currentUpdateTime < skyContext.skySettings.updatePeriod.value) + return; + } + int skyHash = ComputeSkyHash(hdCamera, skyContext, sunLight, ambientMode, staticSky); bool forceUpdate = updateRequired; @@ -745,6 +757,7 @@ public void UpdateEnvironment( HDCamera hdCamera, { using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.UpdateSkyEnvironment))) { + // Debug.Log("Update Sky Lighting"); RenderSkyToCubemap(skyContext); if (updateAmbientProbe) @@ -823,7 +836,7 @@ public void UpdateEnvironment(HDCamera hdCamera, ScriptableRenderContext renderC 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); + UpdateEnvironment(hdCamera, renderContext, m_StaticLightingSky, sunLight, m_StaticSkyUpdateRequired || m_UpdateRequired, true, true, SkyAmbientMode.Static, frameIndex, cmd); m_StaticSkyUpdateRequired = false; } @@ -1059,8 +1072,18 @@ void OnBakeStarted() 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. + // It is possible that HDRP hasn't rendered any frame when clicking the bake lighting button. + // This can happen when baked lighting debug are used for example and no other window with HDRP is visible. + // This will result in the static lighting cubemap not being up to date with what the user put in the Environment Lighting panel. + // We detect this here (basically we just check if the skySetting in the currently processed m_StaticLightingSky is the same as the one the user set). + // And issue a warning if applicable. var staticLightingSky = GetStaticLightingSky(); + if (staticLightingSky != null && staticLightingSky.skySettings != m_StaticLightingSky.skySettings) + { + Debug.LogWarning("Static Lighting Sky is not ready for baking. Please make sure that at least one frame has been rendered with HDRP before baking. For example you can achieve this by having Scene View visible with Draw Mode set to Shaded."); + } + + // 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. if (m_StaticLightingSky.skySettings != null && IsCachedContextValid(m_StaticLightingSky)) { var renderingContext = m_CachedSkyContexts[m_StaticLightingSky.cachedSkyRenderingContextId].renderingContext; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Utilities/HDRenderPipelinePreferences.cs b/com.unity.render-pipelines.high-definition/Runtime/Utilities/HDRenderPipelinePreferences.cs index 8670fb07bab..1ec5c70a209 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Utilities/HDRenderPipelinePreferences.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Utilities/HDRenderPipelinePreferences.cs @@ -32,7 +32,7 @@ public static float matcapViewScale { if (s_MatcapScale == value) return; s_MatcapScale = value; - EditorPrefs.SetFloat(Keys.matcapViewMixAlbedo, s_MatcapScale); + EditorPrefs.SetFloat(Keys.matcapViewScale, s_MatcapScale); } } diff --git a/com.unity.render-pipelines.high-definition/Tests/Editor/XRSystemTests.cs b/com.unity.render-pipelines.high-definition/Tests/Editor/XRSystemTests.cs deleted file mode 100644 index 989b9712505..00000000000 --- a/com.unity.render-pipelines.high-definition/Tests/Editor/XRSystemTests.cs +++ /dev/null @@ -1,78 +0,0 @@ -using NUnit.Framework; -using UnityEngine.TestTools.Constraints; -using Is = UnityEngine.TestTools.Constraints.Is; - -namespace UnityEngine.Rendering.HighDefinition.Tests -{ - class XRSystemTests - { - XRSystem xrSystem; - Camera[] cameras; - - // Simulate multiple frames with many cameras, passes and views - const int k_FrameCount = 90; - const int k_CameraCount = 3; - const int k_PassCount = 4; - const int k_ViewCount = 2; - - [SetUp] - public void SetUp() - { - xrSystem = new XRSystem(null); - TextureXR.maxViews = k_ViewCount; - cameras = new Camera[k_CameraCount]; - for (int cameraIndex = 0; cameraIndex < k_CameraCount; ++cameraIndex) - { - var cameraGameObject = new GameObject(); - cameras[cameraIndex] = cameraGameObject.AddComponent(); - } - - SimulateOneFrame(); - } - - [TearDown] - public void TearDown() - { - xrSystem = null; - cameras = null; - } - - public void SimulateOneFrame() - { - foreach (var camera in cameras) - { - for (int passIndex = 0; passIndex < k_PassCount; ++passIndex) - { - var passCreateInfo = new XRPassCreateInfo - { - multipassId = 0, - cullingPassId = 0, - cullingParameters = new ScriptableCullingParameters(), - renderTarget = camera.targetTexture, - customMirrorView = null - }; - - var xrPass = XRPass.Create(passCreateInfo); - - for (int viewIndex = 0; viewIndex < k_ViewCount; ++viewIndex) - { - xrPass.AddViewInternal(new XRView()); - } - - xrSystem.AddPassToFrame(camera, xrPass); - } - } - - xrSystem.ReleaseFrame(); - } - - [Test] - public void ZeroGCMemoryPerFrame() - { - for (int i = 0; i < k_FrameCount; ++i) - { - Assert.That(() => SimulateOneFrame(), Is.Not.AllocatingGCMemory()); - } - } - } -} diff --git a/com.unity.render-pipelines.high-definition/Tests/Editor/XRSystemTests.cs.meta b/com.unity.render-pipelines.high-definition/Tests/Editor/XRSystemTests.cs.meta deleted file mode 100644 index 245c525f350..00000000000 --- a/com.unity.render-pipelines.high-definition/Tests/Editor/XRSystemTests.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d5dcdb8572b8a1d43903f36f2ae6debb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: