diff --git a/com.unity.render-pipelines.universal/CHANGELOG.md b/com.unity.render-pipelines.universal/CHANGELOG.md index a78d674a4fc..f08d2b27c94 100644 --- a/com.unity.render-pipelines.universal/CHANGELOG.md +++ b/com.unity.render-pipelines.universal/CHANGELOG.md @@ -214,6 +214,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed graphical artefact when terrain height map is used with rendering layer mask for lighting. - Fixed an issue where screen space shadows has flickering with deferred mode [case 1354681](https://issuetracker.unity3d.com/issues/screen-space-shadows-flicker-in-scene-view-when-using-deferred-rendering) - Fixed shadowCascadeBlendCullingFactor to be 1.0 +- Fixed missing property values in a RendererFeature of screen space shadows by adding tooltip for it instead of showing them. [case 1327356] ### Changed - Change Asset/Create/Shader/Universal Render Pipeline/Lit Shader Graph to Asset/Create/Shader Graph/URP/Lit Shader Graph diff --git a/com.unity.render-pipelines.universal/Documentation~/Images/ssshadows/ssshadows-cast-shadow-totransparent.png b/com.unity.render-pipelines.universal/Documentation~/Images/ssshadows/ssshadows-cast-shadow-totransparent.png new file mode 100644 index 00000000000..febb826d9f4 --- /dev/null +++ b/com.unity.render-pipelines.universal/Documentation~/Images/ssshadows/ssshadows-cast-shadow-totransparent.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1dd722fbf9a4d421c79d0268deb6d87b3ee521ca83015fbad9861554bfec4b15 +size 124823 diff --git a/com.unity.render-pipelines.universal/Documentation~/Images/ssshadows/ssshadows-cast-shadow-using-cascades.png b/com.unity.render-pipelines.universal/Documentation~/Images/ssshadows/ssshadows-cast-shadow-using-cascades.png new file mode 100644 index 00000000000..a554f0aeecb --- /dev/null +++ b/com.unity.render-pipelines.universal/Documentation~/Images/ssshadows/ssshadows-cast-shadow-using-cascades.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4305f436505801c1de58c95b69d04c76648d4fce5dbfb9847667801b176c5e95 +size 117093 diff --git a/com.unity.render-pipelines.universal/Documentation~/Images/ssshadows/ssshadows-cast-shadow-using-screenspace.png b/com.unity.render-pipelines.universal/Documentation~/Images/ssshadows/ssshadows-cast-shadow-using-screenspace.png new file mode 100644 index 00000000000..473c13427cd --- /dev/null +++ b/com.unity.render-pipelines.universal/Documentation~/Images/ssshadows/ssshadows-cast-shadow-using-screenspace.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:27fce9027fb66ccf091c59905cefe21e01f13c69df70d63a401e49fe287b756a +size 148745 diff --git a/com.unity.render-pipelines.universal/Documentation~/Images/ssshadows/ssshadows-framedebugger.png b/com.unity.render-pipelines.universal/Documentation~/Images/ssshadows/ssshadows-framedebugger.png new file mode 100644 index 00000000000..29060b06419 --- /dev/null +++ b/com.unity.render-pipelines.universal/Documentation~/Images/ssshadows/ssshadows-framedebugger.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d50ac884c4aedd248d33648eaee620db8e19ca41f6d18de9610c35e99914a87f +size 106816 diff --git a/com.unity.render-pipelines.universal/Documentation~/Images/ssshadows/ssshadows-result.png b/com.unity.render-pipelines.universal/Documentation~/Images/ssshadows/ssshadows-result.png new file mode 100644 index 00000000000..46301367893 --- /dev/null +++ b/com.unity.render-pipelines.universal/Documentation~/Images/ssshadows/ssshadows-result.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8dcbef7182db2dd24ee09b64f4d2e2f6f2b5cc476e4df0c2035b521760c06811 +size 1602863 diff --git a/com.unity.render-pipelines.universal/Documentation~/Images/ssshadows/ssshadows-shadow-texture.png b/com.unity.render-pipelines.universal/Documentation~/Images/ssshadows/ssshadows-shadow-texture.png new file mode 100644 index 00000000000..b3ed67c0c98 --- /dev/null +++ b/com.unity.render-pipelines.universal/Documentation~/Images/ssshadows/ssshadows-shadow-texture.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5d00bcb6e88a04fafdd8d5e2ca932aa4e3421333adb0be88d84b4209d5c342c6 +size 125362 diff --git a/com.unity.render-pipelines.universal/Documentation~/renderer-feature-screen-space-shadows.md b/com.unity.render-pipelines.universal/Documentation~/renderer-feature-screen-space-shadows.md new file mode 100644 index 00000000000..e21c84233f9 --- /dev/null +++ b/com.unity.render-pipelines.universal/Documentation~/renderer-feature-screen-space-shadows.md @@ -0,0 +1,24 @@ +# Screen Space Shadows Renderer Feature + +The Screen Space Shadows [Renderer Feature](urp-renderer-feature.md) calculates screen-space shadows for opaque objects affected by the main directional light and draws them in the scene. To render screen-space shadows, URP requires an additional render target. This increases the amount of memory your application requires, but if your project uses forward rendering, screen-space shadows can benefit the runtime resource intensity. This is because if you use screen-space shadows, URP doesn't need to access the cascade shadow maps multiple times. +![Show screen space shadows](Images/ssshadows/ssshadows-result.png)
*Screen-space shadows in a sample Scene.* + +![Show screen space shadows texture](Images/ssshadows/ssshadows-shadow-texture.png)
*The screen-space shadows texture for the above image.* + +## Enabling screen-space shadows + +To add screen space shadows to your project, [add the Screen Space Shadows Renderer Feature ](urp-renderer-feature-how-to-add.md) to the URP Renderer. + +## Viewing screen-space shadows in the Frame Debugger + +After you enable this Renderer Feature, URP renders screen-space shadows in your scene. To distinguish between shadow map shadows and screen-space shadows, you can view the render passes that draws the shadows in the [Frame Debugger](https://docs.unity3d.com/Manual/FrameDebugger.html). +![Show main light shadows in frame debugger](Images/ssshadows/ssshadows-framedebugger.png)
*Screen Space Shadows pass in frame debugger.* + +You can compare shadows cast on opaque objects from the screen-space shadow texture or the cascade shadow maps. +![Cast Shadows using screen space shadow stexture](Images/ssshadows/ssshadows-cast-shadow-using-screenspace.png)
*The Frame Debugger shows the screen-space shadows texture.* + +![Cast shadows using cascade shadowmaps](Images/ssshadows/ssshadows-cast-shadow-using-cascades.png)
*The Frame Debugger shows shadows from a shadow map.* + +## **Requirements and compatibility** + +This Renderer Feature uses a depth texture and invokes a depth prepass before it draws opaque objects. It calculates the shadows in screen space before the `DrawOpaqueObjects` render pass. URP doesn't calculate or apply screen-space shadows for transparent objects; it uses [shadow maps](urp-shadows.md) for transparent objects instead. ![Won't cast shadows on transparent from screen space shadow texture](Images/ssshadows/ssshadows-cast-shadow-totransparent.png)*
The Frame Debugger showing that Unity uses shadow maps for transparent objects and screen-space shadows for opaque objects.* diff --git a/com.unity.render-pipelines.universal/Editor/RendererFeatures/ScreenSpaceShadowsEditor.cs b/com.unity.render-pipelines.universal/Editor/RendererFeatures/ScreenSpaceShadowsEditor.cs new file mode 100644 index 00000000000..ba30993c0cb --- /dev/null +++ b/com.unity.render-pipelines.universal/Editor/RendererFeatures/ScreenSpaceShadowsEditor.cs @@ -0,0 +1,36 @@ +using UnityEngine; +using UnityEngine.Rendering.Universal; + +namespace UnityEditor.Rendering.Universal +{ + [CustomEditor(typeof(ScreenSpaceShadows))] + internal class ScreenSpaceShadowsEditor : Editor + { + #region Serialized Properties + private SerializedProperty m_SettingsProp; + #endregion + + private bool m_IsInitialized = false; + + private struct Styles + { + public static GUIContent Description = EditorGUIUtility.TrTextContent("Description", "This feature resolves the cascaded shadows in screen space, so there is no options now. It might have additional settings later."); + } + + private void Init() + { + m_SettingsProp = serializedObject.FindProperty("m_Settings"); + m_IsInitialized = true; + } + + public override void OnInspectorGUI() + { + if (!m_IsInitialized) + { + Init(); + } + + EditorGUILayout.PropertyField(m_SettingsProp, Styles.Description); + } + } +} diff --git a/com.unity.render-pipelines.universal/Editor/RendererFeatures/ScreenSpaceShadowsEditor.cs.meta b/com.unity.render-pipelines.universal/Editor/RendererFeatures/ScreenSpaceShadowsEditor.cs.meta new file mode 100644 index 00000000000..8b9a03effff --- /dev/null +++ b/com.unity.render-pipelines.universal/Editor/RendererFeatures/ScreenSpaceShadowsEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d79f23692575f9d4f894c5b5a4b0ccad +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.universal/Shaders/Utils/ScreenSpaceShadows.shader b/com.unity.render-pipelines.universal/Shaders/Utils/ScreenSpaceShadows.shader index ff8d122af33..ed8620e3f39 100644 --- a/com.unity.render-pipelines.universal/Shaders/Utils/ScreenSpaceShadows.shader +++ b/com.unity.render-pipelines.universal/Shaders/Utils/ScreenSpaceShadows.shader @@ -56,15 +56,14 @@ Shader "Hidden/Universal Render Pipeline/ScreenSpaceShadows" deviceDepth = deviceDepth * 2.0 - 1.0; #endif - float3 wpos = ComputeWorldSpacePosition(input.uv.xy, deviceDepth, unity_MatrixInvVP); - //Fetch shadow coordinates for cascade. + float3 wpos = ComputeWorldSpacePosition(input.uv.xy, deviceDepth, unity_MatrixInvVP); float4 coords = TransformWorldToShadowCoord(wpos); // Screenspace shadowmap is only used for directional lights which use orthogonal projection. - ShadowSamplingData shadowSamplingData = GetMainLightShadowSamplingData(); - half4 shadowParams = GetMainLightShadowParams(); - return SampleShadowmap(TEXTURE2D_ARGS(_MainLightShadowmapTexture, sampler_MainLightShadowmapTexture), coords, shadowSamplingData, shadowParams, false); + half realtimeShadow = MainLightRealtimeShadow(coords); + + return realtimeShadow; } ENDHLSL