diff --git a/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs b/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs index 697159b4b37..6d773ae079c 100644 --- a/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs +++ b/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs @@ -50,7 +50,9 @@ public enum ShaderOptions AreaLights = 1, + [System.Obsolete("Deferred shadow can now assume any value, so this field is not used anymore.")] DeferredShadowFiltering = HDShadowFilteringQuality.Medium, + BarnDoor = 0 }; @@ -66,6 +68,7 @@ public class ShaderConfig public static int s_ProbeVolumesAdditiveBlending = (int)ShaderOptions.ProbeVolumesAdditiveBlending; public static int s_AreaLights = (int)ShaderOptions.AreaLights; public static int s_BarnDoor = (int)ShaderOptions.BarnDoor; + [System.Obsolete("Deferred shadow can now assume any value, so this field is not used anymore.")] public static HDShadowFilteringQuality s_DeferredShadowFiltering = (HDShadowFilteringQuality)ShaderOptions.DeferredShadowFiltering; } } diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index eb3d3bf57b7..97934f201e4 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -680,6 +680,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Replaced "High Quality" Volumetric Lighting with "Screen Resolution Percentage" and "Volume Slice Count" on the Fog volume component. - Merged material samples and shader samples - Update material samples scene visuals +- Use multi_compile API for deferred compute shader with shadow mask. ## [7.1.1] - 2019-09-05 diff --git a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Config-Package.md b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Config-Package.md index 0648cf7f790..7bb0541b893 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Config-Package.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Config-Package.md @@ -6,7 +6,6 @@ For example, you can use it to: * Enable [ray tracing](Ray-Tracing-Getting-Started.html). * Enable [camera-relative rendering](Camera-Relative-Rendering.html). -* Control the shadow filtering mode for deferred rendering. ## Using the HDRP Config package @@ -36,7 +35,7 @@ To ensure that the two files are synchronized, you should follow the first metho ### Example -You can use the method described above to change the shadow filtering mode for the [Lit Shader](Lit-Shader.html) in deferred mode: +You can use the method described above to disable [Camera-Relative rendering](Camera-Relative-Rendering.html): -1. In the **ShaderConfig.cs** file, set **DeferredShadowFiltering** to **HDShadowFilteringQuality.High**. -2. Generate the **ShaderConfig.cs.hlsl** file (**Edit > RenderPipeline > Generate Include Files**). Now, in the **ShaderConfig.cs.hlsl** file, the **SHADEROPTIONS_DEFERRED_SHADOW_FILTERING** define should be set to **2** (**#define SHADEROPTIONS_DEFERRED_SHADOW_FILTERING (2)**). \ No newline at end of file +1. In the **ShaderConfig.cs** file, set **CameraRelativeRendering** to **0**. +2. Generate the **ShaderConfig.cs.hlsl** file (**Edit > RenderPipeline > Generate Include Files**). Now, in the **ShaderConfig.cs.hlsl** file, the **SHADEROPTIONS_CAMERA_RELATIVE_RENDERING** define should be set to **0** \ No newline at end of file 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..d9ccbca8c3c 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 @@ -53,10 +53,8 @@ Using high shadow bias values may result in light "leaking" through Meshes. This After HDRP captures a shadow map, it processes filtering on the map in order to decrease the aliasing effect that occurs on low resolution shadow maps. Different filters affect the perceived sharpness of shadows. -To change which filter HDRP uses, the method depends on which filter quality you want to use and whether your HDRP Project uses [forward or deferred rendering](Forward-And-Deferred-Rendering.md). - -* **Forward rendering**: Change the **Filtering Quality** property in your Unity Project’s [HDRP Asset](HDRP-Asset.html). This method works for every filter quality. There are currently three filter quality presets for directional and punctual lights. For information on the available filter qualities, see the [Filtering Qualities table](HDRP-Asset.html#FilteringQualities). -* **Deferred rendering**: For **Low** and **Medium** filter qualities, use the same method as forward rendering. If you want to use **High** quality (PCSS) filtering, you need to enable it in the [HDRP Config package](HDRP-Config-Package.html). For information on how to do this, see the [Example section](HDRP-Config-Package.html#Example) of the Config package documentation. +To change which shadow filter quality to use, change the **Filtering Quality** property in your Unity Project’s [HDRP Asset](HDRP-Asset.html). Higher quality have impact on GPU performance. +There are currently three filter quality presets for directional and punctual lights. For information on the available filter qualities, see the [Filtering Qualities table](HDRP-Asset.html#FilteringQualities). ## Shadowmasks diff --git a/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md b/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md index 7a7bc69294b..515b4103616 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md @@ -15,6 +15,7 @@ * [2019.1 to 2019.2](Upgrading-from-2019.1-to-2019.2) * [2019.2 to 2019.3](Upgrading-from-2019.2-to-2019.3) * [2019.3 to 2020.1](Upgrading-from-2019.3-to-2020.1) + * [2020.1 to 2020.2](Upgrading-from-2020.1-to-2020.2) * Volume Framework * [Volumes](Volumes) * [Volume Profiles](Volume-Profile) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md new file mode 100644 index 00000000000..a642921464f --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md @@ -0,0 +1,8 @@ +# Upgrading HDRP from Unity 2020.1 to Unity 2020.2 + +In the High Definition Render Pipeline (HDRP), some features work differently between major versions of Unity. This document helps you upgrade HDRP from Unity 2020.1 to 2020.2. + +## Shadows + +From Unity 2020.2, it is not necessary to change the [HDRP Config package](HDRP-Config-Package.html) in order to set the [Shadows filtering quality](HDRP-Asset.html#FilteringQualities) for Deferred rendering. Instead the filtering quality can be simply set on the [HDRP Asset](HDRP-Asset.html#FilteringQualities) similarly to what was previously setting only the quality for Forward. + diff --git a/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessShaders.cs b/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessShaders.cs index 1a3b323330a..c48a9c654a5 100644 --- a/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessShaders.cs +++ b/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessShaders.cs @@ -19,6 +19,8 @@ public CommonShaderPreprocessor() { } protected override bool DoShadersStripper(HDRenderPipelineAsset hdrpAsset, Shader shader, ShaderSnippetData snippet, ShaderCompilerData inputData) { + // TODO: We need to perform compute shader stripping as soon as it is possible. Most egregious case would be the shadow filtering quality for Deferred.compute + // Strip every useless shadow configs var shadowInitParams = hdrpAsset.currentPlatformRenderPipelineSettings.hdShadowInitParams; diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs index 0d118994ec2..bd6dd2387bd 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs @@ -349,14 +349,7 @@ static void Drawer_SectionShadows(SerializedHDRenderPipelineAsset serialized, Ed if (!serialized.renderPipelineSettings.supportedLitShaderMode.hasMultipleDifferentValues) { - bool isDeferredOnly = serialized.renderPipelineSettings.supportedLitShaderMode.intValue == (int)RenderPipelineSettings.SupportedLitShaderMode.DeferredOnly; - - // Deferred Only mode does not allow to change filtering quality, but rather it is hardcoded. - if (isDeferredOnly) - serialized.renderPipelineSettings.hdShadowInitParams.shadowFilteringQuality.intValue = (int)ShaderConfig.s_DeferredShadowFiltering; - - using (new EditorGUI.DisabledScope(isDeferredOnly)) - EditorGUILayout.PropertyField(serialized.renderPipelineSettings.hdShadowInitParams.shadowFilteringQuality, Styles.filteringQuality); + EditorGUILayout.PropertyField(serialized.renderPipelineSettings.hdShadowInitParams.shadowFilteringQuality, Styles.filteringQuality); } else { diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Deferred.shader b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Deferred.shader index abe02eecc79..f8ef1337638 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Deferred.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Deferred.shader @@ -38,6 +38,7 @@ Shader "Hidden/HDRP/Deferred" #pragma multi_compile _ OUTPUT_SPLIT_LIGHTING #pragma multi_compile _ SHADOWS_SHADOWMASK #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH #define USE_FPTL_LIGHTLIST // deferred opaque always use FPTL diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/Deferred.compute b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/Deferred.compute index 548dda5ee1c..d97be9b9e81 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/Deferred.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/Deferred.compute @@ -34,6 +34,8 @@ #pragma multi_compile _ SHADOWS_SHADOWMASK +#pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH + #ifdef DEBUG_DISPLAY // Don't care about this warning in debug # pragma warning( disable : 4714 ) // sum of temp registers and indexable temp registers times 256 threads exceeds the recommended total 16384. Performance may be reduced at kernel 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..e0754fde912 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 @@ -39,6 +39,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 SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH #define USE_INDIRECT // otherwise TileVariantToFeatureFlags() will not be defined in Lit.hlsl!!! @@ -301,6 +302,7 @@ Shader "Hidden/HDRP/DeferredTile" #pragma multi_compile _ OUTPUT_SPLIT_LIGHTING #pragma multi_compile _ DEBUG_DISPLAY #pragma multi_compile _ SHADOWS_SHADOWMASK /// Variant with and without shadowmask + #pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH #define USE_FPTL_LIGHTLIST 1 // deferred opaque always use FPTL 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 243396d315c..390ab604361 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 @@ -3816,6 +3816,22 @@ static void RenderComputeDeferredLighting(in DeferredLightingParameters paramete cmd.SetGlobalBuffer(HDShaderIDs.g_vLightListGlobal, resources.lightListBuffer); parameters.deferredComputeShader.shaderKeywords = null; + switch (HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings.hdShadowInitParams.shadowFilteringQuality) + { + case HDShadowFilteringQuality.Low: + parameters.deferredComputeShader.EnableKeyword("SHADOW_LOW"); + break; + case HDShadowFilteringQuality.Medium: + parameters.deferredComputeShader.EnableKeyword("SHADOW_MEDIUM"); + break; + case HDShadowFilteringQuality.High: + parameters.deferredComputeShader.EnableKeyword("SHADOW_HIGH"); + break; + default: + parameters.deferredComputeShader.EnableKeyword("SHADOW_MEDIUM"); + break; + } + if (parameters.enableShadowMasks) { parameters.deferredComputeShader.EnableKeyword("SHADOWS_SHADOWMASK"); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl index 5338c6ae4e5..335301e4902 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl @@ -9,8 +9,7 @@ // Since we use slope-scale bias, the constant bias is for now set as a small fixed value #define FIXED_UNIFORM_BIAS (1.0f / 65536.0f) -// We can't use multi_compile for compute shaders so we force the shadow algorithm -#if SHADERPASS == SHADERPASS_DEFERRED_LIGHTING || (defined(_ENABLE_SHADOW_MATTE) && SHADERPASS == SHADERPASS_FORWARD_UNLIT) +#if (defined(_ENABLE_SHADOW_MATTE) && SHADERPASS == SHADERPASS_FORWARD_UNLIT) #if SHADEROPTIONS_DEFERRED_SHADOW_FILTERING == HDSHADOWFILTERINGQUALITY_LOW #define SHADOW_LOW diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs index 258e010ab2d..3439530ce4b 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs @@ -161,10 +161,10 @@ internal static HDShadowAtlasInitParams GetDefault() shadowResolutionDirectional = new IntScalableSetting(new []{ 256, 512, 1024, 2048 }, ScalableSettingSchemaId.With4Levels), shadowResolutionArea = new IntScalableSetting(new []{ 256, 512, 1024, 2048 }, ScalableSettingSchemaId.With4Levels), shadowResolutionPunctual = new IntScalableSetting(new []{ 256, 512, 1024, 2048 }, ScalableSettingSchemaId.With4Levels), - shadowFilteringQuality = ShaderConfig.s_DeferredShadowFiltering, - supportScreenSpaceShadows = false, - maxScreenSpaceShadowSlots = 4, - screenSpaceShadowBufferFormat = ScreenSpaceShadowFormat.R16G16B16A16, + shadowFilteringQuality = HDShadowFilteringQuality.Medium, + supportScreenSpaceShadows = false, + maxScreenSpaceShadowSlots = 4, + screenSpaceShadowBufferFormat = ScreenSpaceShadowFormat.R16G16B16A16, maxDirectionalShadowMapResolution = 2048, maxAreaShadowMapResolution = 2048, maxPunctualShadowMapResolution = 2048,