From 9169562e71d0dd15a1a77c7c3cf3ee2857ca7e3d Mon Sep 17 00:00:00 2001 From: Erik Hakala Date: Fri, 5 Nov 2021 15:58:08 +0200 Subject: [PATCH 1/2] Remove conditional on shadow offset constants. --- .../AdditionalLightsShadowCasterPass.cs | 13 ++++-------- .../Passes/MainLightShadowCasterPass.cs | 21 +++++++------------ 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/com.unity.render-pipelines.universal/Runtime/Passes/AdditionalLightsShadowCasterPass.cs b/com.unity.render-pipelines.universal/Runtime/Passes/AdditionalLightsShadowCasterPass.cs index c7050766841..ae83372bcfe 100644 --- a/com.unity.render-pipelines.universal/Runtime/Passes/AdditionalLightsShadowCasterPass.cs +++ b/com.unity.render-pipelines.universal/Runtime/Passes/AdditionalLightsShadowCasterPass.cs @@ -84,7 +84,6 @@ public ShadowResolutionRequest(int _visibleLightIndex, int _perLightShadowSliceI bool m_CreateEmptyShadowmap; - bool m_SupportsBoxFilterForShadows; ProfilingSampler m_ProfilingSetupSampler = new ProfilingSampler("Setup Additional Shadows"); int MAX_PUNCTUAL_LIGHT_SHADOW_SLICES_IN_UBO // keep in sync with MAX_PUNCTUAL_LIGHT_SHADOW_SLICES_IN_UBO in Shadows.hlsl @@ -118,7 +117,6 @@ public AdditionalLightsShadowCasterPass(RenderPassEvent evt) m_AdditionalShadowParams_SSBO = Shader.PropertyToID("_AdditionalShadowParams_SSBO"); m_UseStructuredBuffer = RenderingUtils.useStructuredBuffer; - m_SupportsBoxFilterForShadows = Application.isMobilePlatform || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Switch; // Preallocated a fixed size. CommandBuffer.SetGlobal* does allow this data to grow. int maxVisibleAdditionalLights = UniversalRenderPipeline.maxVisibleAdditionalLights; @@ -977,17 +975,14 @@ void SetupAdditionalLightsShadowReceiverConstants(CommandBuffer cmd, ref ShadowD if (softShadows) { - if (m_SupportsBoxFilterForShadows) - { - cmd.SetGlobalVector(AdditionalShadowsConstantBuffer._AdditionalShadowOffset0, + cmd.SetGlobalVector(AdditionalShadowsConstantBuffer._AdditionalShadowOffset0, new Vector4(-invHalfShadowAtlasWidth, -invHalfShadowAtlasHeight, 0.0f, 0.0f)); - cmd.SetGlobalVector(AdditionalShadowsConstantBuffer._AdditionalShadowOffset1, + cmd.SetGlobalVector(AdditionalShadowsConstantBuffer._AdditionalShadowOffset1, new Vector4(invHalfShadowAtlasWidth, -invHalfShadowAtlasHeight, 0.0f, 0.0f)); - cmd.SetGlobalVector(AdditionalShadowsConstantBuffer._AdditionalShadowOffset2, + cmd.SetGlobalVector(AdditionalShadowsConstantBuffer._AdditionalShadowOffset2, new Vector4(-invHalfShadowAtlasWidth, invHalfShadowAtlasHeight, 0.0f, 0.0f)); - cmd.SetGlobalVector(AdditionalShadowsConstantBuffer._AdditionalShadowOffset3, + cmd.SetGlobalVector(AdditionalShadowsConstantBuffer._AdditionalShadowOffset3, new Vector4(invHalfShadowAtlasWidth, invHalfShadowAtlasHeight, 0.0f, 0.0f)); - } // Currently only used when !SHADER_API_MOBILE but risky to not set them as it's generic // enough so custom shaders might use it. diff --git a/com.unity.render-pipelines.universal/Runtime/Passes/MainLightShadowCasterPass.cs b/com.unity.render-pipelines.universal/Runtime/Passes/MainLightShadowCasterPass.cs index 5afe3b6a859..71ae4acfc23 100644 --- a/com.unity.render-pipelines.universal/Runtime/Passes/MainLightShadowCasterPass.cs +++ b/com.unity.render-pipelines.universal/Runtime/Passes/MainLightShadowCasterPass.cs @@ -29,7 +29,6 @@ private static class MainLightShadowConstantBuffer float m_CascadeBorder; float m_MaxShadowDistanceSq; int m_ShadowCasterCascadesCount; - bool m_SupportsBoxFilterForShadows; RenderTargetHandle m_MainLightShadowmap; internal RenderTexture m_MainLightShadowmapTexture; @@ -65,7 +64,6 @@ public MainLightShadowCasterPass(RenderPassEvent evt) MainLightShadowConstantBuffer._ShadowmapSize = Shader.PropertyToID("_MainLightShadowmapSize"); m_MainLightShadowmap.Init("_MainLightShadowmapTexture"); - m_SupportsBoxFilterForShadows = Application.isMobilePlatform || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Switch; } public bool Setup(ref RenderingData renderingData) @@ -284,17 +282,14 @@ void SetupMainLightShadowReceiverConstants(CommandBuffer cmd, VisibleLight shado // This workaround will be removed once we will support soft shadows per light. if (supportsSoftShadows) { - if (m_SupportsBoxFilterForShadows) - { - cmd.SetGlobalVector(MainLightShadowConstantBuffer._ShadowOffset0, - new Vector4(-invHalfShadowAtlasWidth, -invHalfShadowAtlasHeight, 0.0f, 0.0f)); - cmd.SetGlobalVector(MainLightShadowConstantBuffer._ShadowOffset1, - new Vector4(invHalfShadowAtlasWidth, -invHalfShadowAtlasHeight, 0.0f, 0.0f)); - cmd.SetGlobalVector(MainLightShadowConstantBuffer._ShadowOffset2, - new Vector4(-invHalfShadowAtlasWidth, invHalfShadowAtlasHeight, 0.0f, 0.0f)); - cmd.SetGlobalVector(MainLightShadowConstantBuffer._ShadowOffset3, - new Vector4(invHalfShadowAtlasWidth, invHalfShadowAtlasHeight, 0.0f, 0.0f)); - } + cmd.SetGlobalVector(MainLightShadowConstantBuffer._ShadowOffset0, + new Vector4(-invHalfShadowAtlasWidth, -invHalfShadowAtlasHeight, 0.0f, 0.0f)); + cmd.SetGlobalVector(MainLightShadowConstantBuffer._ShadowOffset1, + new Vector4(invHalfShadowAtlasWidth, -invHalfShadowAtlasHeight, 0.0f, 0.0f)); + cmd.SetGlobalVector(MainLightShadowConstantBuffer._ShadowOffset2, + new Vector4(-invHalfShadowAtlasWidth, invHalfShadowAtlasHeight, 0.0f, 0.0f)); + cmd.SetGlobalVector(MainLightShadowConstantBuffer._ShadowOffset3, + new Vector4(invHalfShadowAtlasWidth, invHalfShadowAtlasHeight, 0.0f, 0.0f)); // Currently only used when !SHADER_API_MOBILE but risky to not set them as it's generic // enough so custom shaders might use it. From a4f3c754b853fc27e24f0cc3ba2dd479e271be40 Mon Sep 17 00:00:00 2001 From: Erik Hakala Date: Fri, 5 Nov 2021 17:03:31 +0200 Subject: [PATCH 2/2] Add change log. --- com.unity.render-pipelines.universal/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.universal/CHANGELOG.md b/com.unity.render-pipelines.universal/CHANGELOG.md index a626525faeb..887a83074b1 100644 --- a/com.unity.render-pipelines.universal/CHANGELOG.md +++ b/com.unity.render-pipelines.universal/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fix for rendering thumbnails. [case 1348209](https://issuetracker.unity3d.com/issues/preview-of-assets-do-not-show-in-the-project-window) - Fixed a regression bug where XR camera postion can not be modified in beginCameraRendering [case 1365000] - Fixed an issue in where installing the Adaptive Performance package caused errors to the inspector UI [1368161](https://issuetracker.unity3d.com/issues/urp-package-throws-compilation-error-cs1525-when-imported-together-with-adaptive-performance-package) +- Fixed broken soft shadow filtering. [case 1374960](https://issuetracker.unity3d.com/product/unity/issues/guid/1374960/) ## [13.1.0] - 2021-09-24 ### Added