Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a681128
Add a editor class of screen space shadows
Seongdae Jun 29, 2021
0faa9ca
Merge branch 'master' into urp/fixToHideSettingsOfSSShadows
Seongdae Jul 2, 2021
c9f614f
Missing meta file
Seongdae Jul 2, 2021
473c72d
Apply shadow-fading to a output of screen space shadows
Seongdae Jul 2, 2021
e38368f
Update CHANGELOG.md
Seongdae Jul 2, 2021
b5b3e96
Change shadow-fading on only realtime shadow in screen space shadows …
Seongdae Jul 2, 2021
4dfe365
Fix to fade out main light shadows not using screen space shadows
Seongdae Jul 2, 2021
30b00a9
Add tooltip for screen space shadows
Seongdae Jul 7, 2021
9625ad4
Update CHANGELOG.md
Seongdae Jul 7, 2021
20a1490
Add images for a documentation of screen space shadows
Seongdae Jul 8, 2021
52f13c4
Add a documentation of screen space shadows
Seongdae Jul 8, 2021
31d8ec5
Update a docs of screen space shadows
Seongdae Jul 8, 2021
4a2716b
Update renderer-feature-screen-space-shadows.md
Seongdae Jul 8, 2021
9cca495
Update renderer-feature-screen-space-shadows.md
Seongdae Jul 8, 2021
03679cf
Update renderer-feature-screen-space-shadows.md
Seongdae Jul 8, 2021
c5c9a4e
Update renderer-feature-screen-space-shadows.md
Seongdae Jul 8, 2021
9f03efb
Update renderer-feature-screen-space-shadows.md
Seongdae Jul 8, 2021
019f683
Update renderer-feature-screen-space-shadows.md
Seongdae Jul 8, 2021
1598191
Update renderer-feature-screen-space-shadows.md
Seongdae Jul 8, 2021
97f90e6
Merge branch 'master' into urp/fixToHideSettingsOfSSShadows
Seongdae Aug 26, 2021
f2dae6d
Update renderer-feature-screen-space-shadows.md
Seongdae Sep 3, 2021
c437d56
Reviewed the documentation and removed now unused images
JordanL8 Oct 1, 2021
24495bb
Update images of ssshadows
Seongdae Oct 5, 2021
451068d
Revert to the origin
Seongdae Oct 5, 2021
2405d01
Merge branch 'master' into urp/fixToHideSettingsOfSSShadows
Seongdae Oct 5, 2021
3d323f4
Merge branch 'master' into urp/fixToHideSettingsOfSSShadows
Seongdae Oct 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.universal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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)<br/>*Screen-space shadows in a sample Scene.*

![Show screen space shadows texture](Images/ssshadows/ssshadows-shadow-texture.png)<br/>*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)<br/>*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)<br/>*The Frame Debugger shows the screen-space shadows texture.*

![Cast shadows using cascade shadowmaps](Images/ssshadows/ssshadows-cast-shadow-using-cascades.png)<br/>*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)*<br/>The Frame Debugger showing that Unity uses shadow maps for transparent objects and screen-space shadows for opaque objects.*
Original file line number Diff line number Diff line change
@@ -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);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down