diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/1351_Fabric.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/1351_Fabric.png index c7809a608b5..25db94c5f9c 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/1351_Fabric.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/1351_Fabric.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cb8a12c920996468ee2704198021a2664b46ae20c1ca368f660e4ac56895affc -size 495642 +oid sha256:b1655d445db37e7e433b5bbda8b8e1e087484cfd15f135f03b21fd2377016952 +size 495705 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2311_ShadowMaps.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2311_ShadowMaps.png index 9e391a17345..6af2af15c64 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2311_ShadowMaps.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2311_ShadowMaps.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:31b4664a8110e8007b726bb4787d14dd05383dab22a0f01df241f8ce6032b950 -size 178998 +oid sha256:b2e86cf6a9642b59a84a2a4ad0c4530ee7c663a544ef08caec34a66d3fac1f6e +size 179027 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/5008_FogFiltering.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/5008_FogFiltering.png index d6cb5f62d67..5d0afa619f3 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/5008_FogFiltering.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/5008_FogFiltering.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ffcead2fc94ff56e441703a558005b97091a8099ebdead1a6db4bf2646424b99 -size 154163 +oid sha256:a9e2ab64262fe8b62673f00101b3771745287b1765632f15450f54c5619373ba +size 135960 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/8102_Transparent.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/8102_Transparent.png index be09205e4b8..93bcb288c96 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/8102_Transparent.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/8102_Transparent.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a03d75114e65733f82c46b699d31938e6a328b5ea6d5afb6713823b8fd558ef4 -size 266343 +oid sha256:b4360682982f0320920382ff0da6b875c6ce3045103bb7b811bc199444bbb7e6 +size 274116 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/8103_PrePostPass.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/8103_PrePostPass.png index cbfd0da989e..5f2d4724844 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/8103_PrePostPass.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/8103_PrePostPass.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ba613e9b97540937c64d11a18a2e3ad9b8fb546003ad9acacc22a5f321275168 -size 96969 +oid sha256:9bc2b31bf19784f71c1f8d9dda1e6ca7188b7d6ff99c3f58d14157cdf9adfa6b +size 97485 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/8106_UnlitShadowMatte.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/8106_UnlitShadowMatte.png index 24abed5d065..142d35929f1 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/8106_UnlitShadowMatte.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/8106_UnlitShadowMatte.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4d5174a473588418dfd57a13bdba3ee131850cbd16c5a49d6cfba8bc7ef3069e -size 390193 +oid sha256:dc2e5be66d21038eeb85288dddf821e59f2f83d3e0cf6042da282323cc01787a +size 391409 diff --git a/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl index 2c5139393d7..5426df87957 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl @@ -1260,4 +1260,7 @@ float SharpenAlpha(float alpha, float alphaClipTreshold) return saturate((alpha - alphaClipTreshold) / max(fwidth(alpha), 0.0001) + 0.5); } +// These clamping function to max of floating point 16 bit are use to prevent INF in code in case of extreme value +TEMPLATE_1_REAL(ClampToFloat16Max, value, return min(value, HALF_MAX)) + #endif // UNITY_COMMON_INCLUDED diff --git a/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl index fb7e74e057e..02cf0a902ce 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl @@ -1,9 +1,6 @@ #ifndef UNITY_COMMON_LIGHTING_INCLUDED #define UNITY_COMMON_LIGHTING_INCLUDED -// These clamping function to max of floating point 16 bit are use to prevent INF in code in case of extreme value -TEMPLATE_1_REAL(ClampToFloat16Max, value, return min(value, HALF_MAX)) - // Ligthing convention // Light direction is oriented backward (-Z). i.e in shader code, light direction is -lightData.forward 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 index a642921464f..1c53f78fed6 100644 --- 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 @@ -4,5 +4,5 @@ In the High Definition Render Pipeline (HDRP), some features work differently be ## 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. +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. Note that if previously the Shadow filtering quality wasn't setup on medium on the HDRP Asset you will experience a change of shadow quality as now it will be taken into account. diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitPass.template b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitPass.template index 3e24948e532..53d024438ac 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitPass.template +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitPass.template @@ -48,7 +48,6 @@ Pass #if defined(_ENABLE_SHADOW_MATTE) && SHADERPASS == SHADERPASS_FORWARD_UNLIT #define LIGHTLOOP_DISABLE_TILE_AND_CLUSTER #define HAS_LIGHTLOOP - #define SHADOW_OPTIMIZE_REGISTER_USAGE 1 #endif // Dots Instancing diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitSubTarget.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitSubTarget.cs index 64fdfb7b6f0..0ec0d65f66b 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitSubTarget.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitSubTarget.cs @@ -1,4 +1,4 @@ -using UnityEngine.Rendering.HighDefinition; +using UnityEngine.Rendering.HighDefinition; using UnityEditor.ShaderGraph; namespace UnityEditor.Rendering.HighDefinition.ShaderGraph @@ -500,6 +500,7 @@ static class UnlitKeywords { { CoreKeywords.HDBase }, { CoreKeywordDescriptors.DebugDisplay }, + { CoreKeywordDescriptors.Shadow, new FieldCondition(HDFields.EnableShadowMatte, true) }, }; } #endregion @@ -551,8 +552,6 @@ static class UnlitIncludes { CoreIncludes.kUnlit, IncludeLocation.Pregraph }, { CoreIncludes.CoreUtility }, { CoreIncludes.kShaderGraphFunctions, IncludeLocation.Pregraph }, - { CoreIncludes.kCommonLighting, IncludeLocation.Pregraph, new FieldCondition(HDFields.EnableShadowMatte, true) }, - { CoreIncludes.kShadowContext, IncludeLocation.Pregraph, new FieldCondition(HDFields.EnableShadowMatte, true) }, { CoreIncludes.kHDShadow, IncludeLocation.Pregraph, new FieldCondition(HDFields.EnableShadowMatte, true) }, { CoreIncludes.kLightLoopDef, IncludeLocation.Pregraph, new FieldCondition(HDFields.EnableShadowMatte, true) }, { CoreIncludes.kPunctualLightCommon, IncludeLocation.Pregraph, new FieldCondition(HDFields.EnableShadowMatte, true) }, diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/UnlitSubTarget.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/UnlitSubTarget.cs index cda904e70d2..69f4cbaae38 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/UnlitSubTarget.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/UnlitSubTarget.cs @@ -1,4 +1,4 @@ -using UnityEngine.Rendering.HighDefinition; +using UnityEngine.Rendering.HighDefinition; using UnityEditor.ShaderGraph; namespace UnityEditor.Rendering.HighDefinition.ShaderGraph @@ -341,7 +341,6 @@ static class UnlitIncludes { CoreIncludes.CoreUtility }, { CoreIncludes.kShaderGraphFunctions, IncludeLocation.Pregraph }, { CoreIncludes.kCommonLighting, IncludeLocation.Pregraph, new FieldCondition(HDFields.EnableShadowMatte, true) }, - { CoreIncludes.kShadowContext, IncludeLocation.Pregraph, new FieldCondition(HDFields.EnableShadowMatte, true) }, { CoreIncludes.kHDShadow, IncludeLocation.Pregraph, new FieldCondition(HDFields.EnableShadowMatte, true) }, { CoreIncludes.kLightLoopDef, IncludeLocation.Pregraph, new FieldCondition(HDFields.EnableShadowMatte, true) }, { CoreIncludes.kPunctualLightCommon, IncludeLocation.Pregraph, new FieldCondition(HDFields.EnableShadowMatte, true) }, diff --git a/com.unity.render-pipelines.high-definition/Editor/ShaderGraph/HDTarget.cs b/com.unity.render-pipelines.high-definition/Editor/ShaderGraph/HDTarget.cs index f5a96f6c335..2a4db79adbf 100644 --- a/com.unity.render-pipelines.high-definition/Editor/ShaderGraph/HDTarget.cs +++ b/com.unity.render-pipelines.high-definition/Editor/ShaderGraph/HDTarget.cs @@ -674,7 +674,6 @@ static class CoreIncludes // Public Pregraph Function public const string kCommonLighting = "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl"; - public const string kShadowContext = "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowContext.hlsl"; public const string kHDShadow = "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadow.hlsl"; public const string kLightLoopDef = "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl"; public const string kPunctualLightCommon = "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/PunctualLightCommon.hlsl"; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugViewTiles.shader b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugViewTiles.shader index a41a2557b7e..50eb0437b7a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugViewTiles.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugViewTiles.shader @@ -28,7 +28,6 @@ Shader "Hidden/HDRP/DebugViewTiles" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl" - #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" #define DEBUG_DISPLAY diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl index e39cea36c3f..ea8354f75c9 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl @@ -9,6 +9,12 @@ #define DWORD_PER_TILE 16 // See dwordsPerTile in LightLoop.cs, we have roomm for 31 lights and a number of light value all store on 16 bit (ushort) +// Some file may not required HD shadow context at all. In this case provide an empty one +// Note: if a double defintion error occur it is likely have include HDShadow.hlsl (and so HDShadowContext.hlsl) after lightloopdef.hlsl +#ifndef HAVE_HD_SHADOW_CONTEXT +struct HDShadowContext { float unused; }; +#endif + // LightLoopContext is not visible from Material (user should not use these properties in Material file) // It allow the lightloop to have transmit sampling information (do we use atlas, or texture array etc...) struct LightLoopContext diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.compute b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.compute index 049c9f96981..98ac679de1f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.compute @@ -11,7 +11,6 @@ #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/NormalBuffer.hlsl" #define USE_FPTL_LIGHTLIST // Use light tiles for contact shadows -#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.hlsl" 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 335301e4902..d52b1c8d43f 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 @@ -1,31 +1,10 @@ -// Various shadow algorithms -// There are two variants provided, one takes the texture and sampler explicitly so they can be statically passed in. -// The variant without resource parameters dynamically accesses the texture when sampling. - -// WARNINGS: -// Keep in sync with HDShadowManager::GetDirectionalShadowAlgorithm() -// Be careful this require to update GetPunctualFilterWidthInTexels() in C# as well! +// Configure which shadow algorithms to use per shadow level quality // 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) -#if (defined(_ENABLE_SHADOW_MATTE) && SHADERPASS == SHADERPASS_FORWARD_UNLIT) - - #if SHADEROPTIONS_DEFERRED_SHADOW_FILTERING == HDSHADOWFILTERINGQUALITY_LOW - #define SHADOW_LOW - #elif SHADEROPTIONS_DEFERRED_SHADOW_FILTERING == HDSHADOWFILTERINGQUALITY_MEDIUM - #define SHADOW_MEDIUM - #elif SHADEROPTIONS_DEFERRED_SHADOW_FILTERING == HDSHADOWFILTERINGQUALITY_HIGH - #define SHADOW_HIGH - #else - #define SHADOW_MEDIUM - #endif - -#endif - -#if (SHADERPASS == SHADERPASS_VOLUMETRIC_LIGHTING || SHADERPASS == SHADERPASS_VOLUME_VOXELIZATION) -#define SHADOW_LOW -#endif +// WARNINGS: +// Keep in sync with both HDShadowManager::GetDirectionalShadowAlgorithm() and GetPunctualFilterWidthInTexels() in C# as well! #ifdef SHADOW_LOW #define PUNCTUAL_FILTER_ALGORITHM(sd, posSS, posTC, tex, samp, bias) SampleShadow_PCF_Tent_3x3(_ShadowAtlasSize.zwxy, posTC, tex, samp, bias) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowContext.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowContext.hlsl index f4efd5e36f6..dfee6ffa597 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowContext.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowContext.hlsl @@ -4,6 +4,9 @@ #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs.hlsl" +// Say to LightloopDefs.hlsl that we have a sahdow context struct define +#define HAVE_HD_SHADOW_CONTEXT + struct HDShadowContext { StructuredBuffer shadowDatas; 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 3439530ce4b..baca84547a9 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 @@ -298,6 +298,7 @@ public void InitShadowManager(RenderPipelineResources renderPipelineResources, D m_MaxShadowRequests = maxShadowRequests; } + // Keep in sync with both HDShadowSampling.hlsl public static DirectionalShadowAlgorithm GetDirectionalShadowAlgorithm() { switch (HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings.hdShadowInitParams.shadowFilteringQuality) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowSampling.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowSampling.hlsl index 944ca2acaf8..aac441d7899 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowSampling.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowSampling.hlsl @@ -68,7 +68,7 @@ real SampleShadow_PCF_Tent_5x5(float4 shadowAtlasSize, float3 coord, Texture2D t #else for (int i = 0; i < 9; i++) { - shadow += fetchesWeights[i] * SAMPLE_TEXTURE2D_SHADOW(tex, compSamp, real3(fetchesUV[i].xy, coord.z), slice).x; + shadow += fetchesWeights[i] * SAMPLE_TEXTURE2D_SHADOW(tex, compSamp, real3(fetchesUV[i].xy, coord.z)).x; } #endif @@ -128,7 +128,7 @@ real SampleShadow_PCF_Tent_7x7(float4 shadowAtlasSize, float3 coord, Texture2D t #else for(int i = 0; i < 16; i++) { - shadow += fetchesWeights[i] * SAMPLE_TEXTURE2D_SHADOW(tex, compSamp, real3(fetchesUV[i].xy, coord.z).x; + shadow += fetchesWeights[i] * SAMPLE_TEXTURE2D_SHADOW(tex, compSamp, real3(fetchesUV[i].xy, coord.z)).x; } #endif diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowUtils.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowUtils.cs index c4f643e029d..4b9fb0c4a5f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowUtils.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowUtils.cs @@ -15,6 +15,7 @@ static class HDShadowUtils static Plane[] s_CachedPlanes = new Plane[6]; + // Keep in sync with both HDShadowSampling.hlsl static float GetPunctualFilterWidthInTexels(HDShadowFilteringQuality quality) { switch (quality) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManager.cs index 8aa98999558..6d46c1fbad4 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManager.cs @@ -203,6 +203,22 @@ void InitializeScreenSpaceShadows() // Directional shadow material s_ScreenSpaceShadowsMat = CoreUtils.CreateEngineMaterial(screenSpaceShadowsShader); + switch (m_Asset.currentPlatformRenderPipelineSettings.hdShadowInitParams.shadowFilteringQuality) + { + case HDShadowFilteringQuality.Low: + s_ScreenSpaceShadowsMat.EnableKeyword("SHADOW_LOW"); + break; + case HDShadowFilteringQuality.Medium: + s_ScreenSpaceShadowsMat.EnableKeyword("SHADOW_MEDIUM"); + break; + case HDShadowFilteringQuality.High: + s_ScreenSpaceShadowsMat.EnableKeyword("SHADOW_HIGH"); + break; + default: + s_ScreenSpaceShadowsMat.EnableKeyword("SHADOW_MEDIUM"); + break; + } + // Allocate the final result texture int numShadowTextures = Math.Max((int)Math.Ceiling(m_Asset.currentPlatformRenderPipelineSettings.hdShadowInitParams.maxScreenSpaceShadowSlots / 4.0f), 1); GraphicsFormat graphicsFormat = (GraphicsFormat)m_Asset.currentPlatformRenderPipelineSettings.hdShadowInitParams.screenSpaceShadowBufferFormat; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadows.shader b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadows.shader index 4ffd39c9568..8f9544fa806 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadows.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadows.shader @@ -2,10 +2,11 @@ Shader "Hidden/HDRP/ScreenSpaceShadows" { HLSLINCLUDE - - #pragma target 4.5 #pragma only_renderers d3d11 playstation xboxone vulkan metal switch + + #pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH + #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Builtin/BuiltinData.hlsl" diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumeVoxelization.compute b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumeVoxelization.compute index a26479a67fd..e273788aa24 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumeVoxelization.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumeVoxelization.compute @@ -29,19 +29,11 @@ #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/GeometricTools.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/VolumeRendering.hlsl" -#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/TextureXR.hlsl" -#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Core/Utilities/GeometryUtils.cs.hlsl" - -#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl" -#define SHADERPASS SHADERPASS_VOLUME_VOXELIZATION - #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl" +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Core/Utilities/GeometryUtils.cs.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.cs.hlsl" - -#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" - //-------------------------------------------------------------------------------------------------- // Inputs & outputs //-------------------------------------------------------------------------------------------------- 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 7874d5c8ad8..b788835f707 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 @@ -55,6 +55,9 @@ #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VBuffer.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyCommon.hlsl" + +// Use low quality shadow when doing volumetric +#define SHADOW_LOW #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl" 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 b2aaf9a07fc..942927c7267 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -2341,11 +2341,11 @@ void Callback(CommandBuffer c, HDCamera cam) m_AmbientOcclusionSystem.Render(cmd, hdCamera, renderContext, m_FrameCount); // Run the contact shadows here as they need the light list - HDUtils.CheckRTCreated(m_ContactShadowBuffer); - RenderContactShadows(hdCamera, cmd); - PushFullScreenDebugTexture(hdCamera, cmd, m_ContactShadowBuffer, FullScreenDebugMode.ContactShadows); + HDUtils.CheckRTCreated(m_ContactShadowBuffer); + RenderContactShadows(hdCamera, cmd); + PushFullScreenDebugTexture(hdCamera, cmd, m_ContactShadowBuffer, FullScreenDebugMode.ContactShadows); - RenderScreenSpaceShadows(hdCamera, cmd); + RenderScreenSpaceShadows(hdCamera, cmd); if (hdCamera.frameSettings.VolumeVoxelizationRunsAsync()) { diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs index 6a28a727ebd..4cbe667b0a0 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs @@ -16,7 +16,6 @@ enum ShaderPass LightTransport, Shadows, SubsurfaceScattering, - VolumeVoxelization, VolumetricLighting, DbufferProjector, DbufferMesh, diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl index 1a0c51fe34d..fa2fad1b720 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl @@ -17,20 +17,19 @@ #define SHADERPASS_LIGHT_TRANSPORT (7) #define SHADERPASS_SHADOWS (8) #define SHADERPASS_SUBSURFACE_SCATTERING (9) -#define SHADERPASS_VOLUME_VOXELIZATION (10) -#define SHADERPASS_VOLUMETRIC_LIGHTING (11) -#define SHADERPASS_DBUFFER_PROJECTOR (12) -#define SHADERPASS_DBUFFER_MESH (13) -#define SHADERPASS_FORWARD_EMISSIVE_PROJECTOR (14) -#define SHADERPASS_FORWARD_EMISSIVE_MESH (15) -#define SHADERPASS_RAYTRACING (16) -#define SHADERPASS_RAYTRACING_INDIRECT (17) -#define SHADERPASS_RAYTRACING_VISIBILITY (18) -#define SHADERPASS_RAYTRACING_FORWARD (19) -#define SHADERPASS_RAYTRACING_GBUFFER (20) -#define SHADERPASS_RAYTRACING_SUB_SURFACE (21) -#define SHADERPASS_PATH_TRACING (22) -#define SHADERPASS_CONSTANT (23) +#define SHADERPASS_VOLUMETRIC_LIGHTING (10) +#define SHADERPASS_DBUFFER_PROJECTOR (11) +#define SHADERPASS_DBUFFER_MESH (12) +#define SHADERPASS_FORWARD_EMISSIVE_PROJECTOR (13) +#define SHADERPASS_FORWARD_EMISSIVE_MESH (14) +#define SHADERPASS_RAYTRACING (15) +#define SHADERPASS_RAYTRACING_INDIRECT (16) +#define SHADERPASS_RAYTRACING_VISIBILITY (17) +#define SHADERPASS_RAYTRACING_FORWARD (18) +#define SHADERPASS_RAYTRACING_GBUFFER (19) +#define SHADERPASS_RAYTRACING_SUB_SURFACE (20) +#define SHADERPASS_PATH_TRACING (21) +#define SHADERPASS_CONSTANT (22) #endif