From 36ec2088fd59e8fcd66130f751a4d3d24dad63f1 Mon Sep 17 00:00:00 2001 From: Julien Ignace Date: Thu, 1 Oct 2020 17:37:32 +0200 Subject: [PATCH 1/5] Current LOD bias and max values for scene view rendering is now using the default frame settings. This makes LODGroup UI consistent with what is happening on screen. --- .../Runtime/RenderPipeline/HDRenderPipeline.cs | 5 +++++ 1 file changed, 5 insertions(+) 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 1b0f567cb62..6a209f3a735 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -383,6 +383,11 @@ public HDRenderPipeline(HDRenderPipelineAsset asset, HDRenderPipelineAsset defau SetRenderingFeatures(); + // Initialize lod settings with the default frame settings. This will pull LoD values from the current quality level HDRP asset if necessary. + // This will make the LoD Group UI consistent with the scene view camera like it is for builtin pipeline. + QualitySettings.lodBias = m_Asset.GetDefaultFrameSettings(FrameSettingsRenderType.Camera).GetResolvedLODBias(m_Asset); + QualitySettings.maximumLODLevel = m_Asset.GetDefaultFrameSettings(FrameSettingsRenderType.Camera).GetResolvedMaximumLODLevel(m_Asset); + // The first thing we need to do is to set the defines that depend on the render pipeline settings m_RayTracingSupported = GatherRayTracingSupport(m_Asset.currentPlatformRenderPipelineSettings); From bc45ff5b6f19e833fe9c4588abce8395a8a6b729 Mon Sep 17 00:00:00 2001 From: Julien Ignace Date: Thu, 1 Oct 2020 17:38:04 +0200 Subject: [PATCH 2/5] LOD Meshes are now properly stripped depending on the Max LOD value stored in all HDRP assets of a build. --- .../BuildProcessors/HDRPPreprocessBuild.cs | 50 ++++++++++++++++--- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessBuild.cs b/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessBuild.cs index 743e237397d..4282db7752d 100644 --- a/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessBuild.cs +++ b/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessBuild.cs @@ -10,6 +10,23 @@ class HDRPPreprocessBuild : IPreprocessBuildWithReport { public int callbackOrder { get { return 0; } } + int GetMinimumMaxLoDValue(HDRenderPipelineAsset asset) + { + int minimumMaxLoD = int.MaxValue; + var maxLoDs = asset.currentPlatformRenderPipelineSettings.maximumLODLevel; + var schema = ScalableSettingSchema.GetSchemaOrNull(maxLoDs.schemaId); + for (int lod = 0; lod < schema.levelCount; ++lod) + { + if (maxLoDs.TryGet(lod, out int maxLoD)) + minimumMaxLoD = Mathf.Min(minimumMaxLoD, maxLoD); + } + + if (minimumMaxLoD != int.MaxValue) + return minimumMaxLoD; + else + return 0; + } + public void OnPreprocessBuild(BuildReport report) { // Detect if the users forget to assign an HDRP Asset @@ -38,16 +55,35 @@ public void OnPreprocessBuild(BuildReport report) // If platform is supported all good GraphicsDeviceType unsupportedGraphicDevice = GraphicsDeviceType.Null; - if (HDUtils.AreGraphicsAPIsSupported(report.summary.platform, out unsupportedGraphicDevice) + bool supported = HDUtils.AreGraphicsAPIsSupported(report.summary.platform, out unsupportedGraphicDevice) && HDUtils.IsSupportedBuildTarget(report.summary.platform) - && HDUtils.IsOperatingSystemSupported(SystemInfo.operatingSystem)) - return; + && HDUtils.IsOperatingSystemSupported(SystemInfo.operatingSystem); - unsupportedGraphicDevice = (unsupportedGraphicDevice == GraphicsDeviceType.Null) ? SystemInfo.graphicsDeviceType : unsupportedGraphicDevice; - string msg = "The platform " + report.summary.platform.ToString() + " with the graphic API " + unsupportedGraphicDevice + " is not supported with High Definition Render Pipeline"; + if (!supported) + { + unsupportedGraphicDevice = (unsupportedGraphicDevice == GraphicsDeviceType.Null) ? SystemInfo.graphicsDeviceType : unsupportedGraphicDevice; + string msg = "The platform " + report.summary.platform.ToString() + " with the graphic API " + unsupportedGraphicDevice + " is not supported with High Definition Render Pipeline"; - // Throw an exception to stop the build - throw new BuildFailedException(msg); + // Throw an exception to stop the build + throw new BuildFailedException(msg); + } + + // Update all quality levels with the right max lod so that meshes can be stripped. + // We don't take lod bias into account because it can be overridden per camera. + int qualityLevelCount = QualitySettings.names.Length; + for (int i = 0; i < qualityLevelCount; ++i) + { + QualitySettings.SetQualityLevel(i, false); + var renderPipeline = QualitySettings.renderPipeline as HDRenderPipelineAsset; + if (renderPipeline != null) + { + QualitySettings.maximumLODLevel = GetMinimumMaxLoDValue(renderPipeline); + } + else + { + QualitySettings.maximumLODLevel = GetMinimumMaxLoDValue(hdPipelineAsset); + } + } } } } From 364be681b753639afaba0ac105c36d56495e5a89 Mon Sep 17 00:00:00 2001 From: Julien Ignace Date: Thu, 1 Oct 2020 17:38:50 +0200 Subject: [PATCH 3/5] Added a section about LOD management in the feature comparison with builtin to explain the differences and that the QualitySettings lod APIs aren't supported anymore. --- .../Documentation~/Feature-Comparison.md | 7 +++++++ 1 file changed, 7 insertions(+) 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 0662ad53939..575a682be85 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Feature-Comparison.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Feature-Comparison.md @@ -210,6 +210,13 @@ The tables that follow provide an overview of the **Features** that the High Def | Hair | Not supported | Yes | | Fabric | Not supported | Yes | +## LOD Management +In the builtin render pipeline, LOD is managed from the QualitySettings. Each quality setting can define a LOD Bias and a Maximum LOD value. As such, they are global to this quality setting and cannot be changed per camera. In HDRP, things are different. As described [here](HDRP-Asset.md) and [here](Frame-Settings.md), HDRP introduces the notion of scalability settings. This allows user to change the LOD settings per camera by using either predetermined values contained in the HDRP asset of the current quality level or overridden values. + +This has two consequences: +- Default LOD settings for a quality level are now stored in the HDRP asset instead of the Quality Settings. +- Builtin APIs such as QualitySettings.lodBias or QualitySettings.maximumLODLevel are not supported anymore. Instead, users need to change them through the camera frame settings. Using them will have no effect at all. + ## Render Pipeline Hooks | **Feature** | **Built-in Render Pipeline** | **High Definition Render Pipeline (HDRP)** | From eb333452016603268550f3359a5792ca2890b109 Mon Sep 17 00:00:00 2001 From: Julien Ignace Date: Thu, 1 Oct 2020 17:44:36 +0200 Subject: [PATCH 4/5] Update changelog --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index eed9eae1dd7..beb0fdb026c 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -117,6 +117,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed issue with box light not visible if range is below one and range attenuation is off. - Fixed alpha not having TAA applied to it. - Fixed issue with bloom showing a thin black line after rescaling window. +- LOD meshes are now properly stripped based on the maximum lod value parameters contained in the HDRP asset. +- Fixed an inconsistency in the LOD group UI where LOD bias was not the right one. ### Changed - Preparation pass for RTSSShadows to be supported by render graph. From cd0c9a2b67b39fe94b633c80acde464e9a3b8d3b Mon Sep 17 00:00:00 2001 From: Julien Ignace Date: Fri, 2 Oct 2020 13:35:07 +0200 Subject: [PATCH 5/5] Updated doc with review feedback. --- .../Documentation~/Feature-Comparison.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 575a682be85..d01f5467374 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Feature-Comparison.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Feature-Comparison.md @@ -211,11 +211,11 @@ The tables that follow provide an overview of the **Features** that the High Def | Fabric | Not supported | Yes | ## LOD Management -In the builtin render pipeline, LOD is managed from the QualitySettings. Each quality setting can define a LOD Bias and a Maximum LOD value. As such, they are global to this quality setting and cannot be changed per camera. In HDRP, things are different. As described [here](HDRP-Asset.md) and [here](Frame-Settings.md), HDRP introduces the notion of scalability settings. This allows user to change the LOD settings per camera by using either predetermined values contained in the HDRP asset of the current quality level or overridden values. +In the Built-in Render Pipeline, you manage levels of detail (LOD) from the QualitySettings. Each quality setting defines a LOD Bias and a Maximum LOD value. As such, they are global to the quality setting and you cannot change them on a per camera basis. In HDRP, there are scalability settings that allow you to change the LOD settings per camera by using either predetermined values contained in the HDRP Asset of the current quality level or overridden values. For more information, see [HDRP Asset](HDRP-Asset.md) and [Frame Settings](Frame-Settings.md). -This has two consequences: -- Default LOD settings for a quality level are now stored in the HDRP asset instead of the Quality Settings. -- Builtin APIs such as QualitySettings.lodBias or QualitySettings.maximumLODLevel are not supported anymore. Instead, users need to change them through the camera frame settings. Using them will have no effect at all. +Managing LOD in this way has two consequences: +- Default LOD settings for a quality level are now stored in the HDRP Asset instead of the Quality Settings. +- Built-in APIs such as QualitySettings.lodBias or QualitySettings.maximumLODLevel no longer work. Instead, you need to change these properties through the camera Frame Settings. If you use the Built-in APIs, they have no effect at all. ## Render Pipeline Hooks