Skip to content

Commit 03f80d5

Browse files
NzollnerEvergreen
authored andcommitted
Fixed light.useViewFrustumForShadowCasterCull for shadow cascades
This fixes UUM-56026
1 parent 9697995 commit 03f80d5

18 files changed

+3330
-0
lines changed

Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/CommonAssets/URPAssets/DefaultURPAsset.asset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ MonoBehaviour:
4444
- {fileID: 11400000, guid: 32bad5b5f60f85349bb6751a615e4571, type: 2}
4545
- {fileID: 11400000, guid: c24cfbcb0b49eb642b5173d4d3478f4d, type: 2}
4646
- {fileID: 11400000, guid: 81afd9c2ea9393c4589e79894b0c709b, type: 2}
47+
- {fileID: 11400000, guid: dbd02dcdb14e40d4ab5ea07210293f4a, type: 2}
4748
m_DefaultRendererIndex: 0
4849
m_RequireDepthTexture: 1
4950
m_RequireOpaqueTexture: 1

Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/CommonAssets/URPAssets/ScreenSpaceShadowsURPAsset.asset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ MonoBehaviour:
1818
m_RendererData: {fileID: 0}
1919
m_RendererDataList:
2020
- {fileID: 11400000, guid: 3f63a62897927184393f03bfcc44365a, type: 2}
21+
- {fileID: 11400000, guid: dbd02dcdb14e40d4ab5ea07210293f4a, type: 2}
2122
m_DefaultRendererIndex: 0
2223
m_RequireDepthTexture: 1
2324
m_RequireOpaqueTexture: 1

Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: de640fe3d0db1804a85f9fc8f5cadab6, type: 3}
13+
m_Name: ForwardRenderer_MainlightShadowOutput
14+
m_EditorClassIdentifier:
15+
debugShaders:
16+
debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7,
17+
type: 3}
18+
hdrDebugViewPS: {fileID: 4800000, guid: 573620ae32aec764abd4d728906d2587, type: 3}
19+
probeVolumeSamplingDebugComputeShader: {fileID: 7200000, guid: 53626a513ea68ce47b59dc1299fe3959,
20+
type: 3}
21+
probeVolumeResources:
22+
probeVolumeDebugShader: {fileID: 0}
23+
probeVolumeFragmentationDebugShader: {fileID: 0}
24+
probeVolumeOffsetDebugShader: {fileID: 0}
25+
probeVolumeSamplingDebugShader: {fileID: 0}
26+
probeSamplingDebugMesh: {fileID: 0}
27+
probeSamplingDebugTexture: {fileID: 0}
28+
probeVolumeBlendStatesCS: {fileID: 0}
29+
m_RendererFeatures:
30+
- {fileID: 7458500041116228135}
31+
m_RendererFeatureMap: 271af84345ea8167
32+
m_UseNativeRenderPass: 0
33+
xrSystemData: {fileID: 0}
34+
postProcessData: {fileID: 0}
35+
m_AssetVersion: 2
36+
m_OpaqueLayerMask:
37+
serializedVersion: 2
38+
m_Bits: 4294967295
39+
m_TransparentLayerMask:
40+
serializedVersion: 2
41+
m_Bits: 4294967295
42+
m_DefaultStencilState:
43+
overrideStencilState: 0
44+
stencilReference: 0
45+
stencilCompareFunction: 8
46+
passOperation: 2
47+
failOperation: 0
48+
zFailOperation: 0
49+
m_ShadowTransparentReceive: 1
50+
m_RenderingMode: 0
51+
m_DepthPrimingMode: 0
52+
m_CopyDepthMode: 1
53+
m_DepthAttachmentFormat: 0
54+
m_DepthTextureFormat: 0
55+
m_AccurateGbufferNormals: 0
56+
m_IntermediateTextureMode: 1
57+
--- !u!114 &1518851271565517769
58+
MonoBehaviour:
59+
m_ObjectHideFlags: 0
60+
m_CorrespondingSourceObject: {fileID: 0}
61+
m_PrefabInstance: {fileID: 0}
62+
m_PrefabAsset: {fileID: 0}
63+
m_GameObject: {fileID: 0}
64+
m_Enabled: 1
65+
m_EditorHideFlags: 0
66+
m_Script: {fileID: 0}
67+
m_Name: OutputTexture
68+
m_EditorClassIdentifier:
69+
m_Active: 1
70+
m_TextureType: 0
71+
--- !u!114 &7458500041116228135
72+
MonoBehaviour:
73+
m_ObjectHideFlags: 0
74+
m_CorrespondingSourceObject: {fileID: 0}
75+
m_PrefabInstance: {fileID: 0}
76+
m_PrefabAsset: {fileID: 0}
77+
m_GameObject: {fileID: 0}
78+
m_Enabled: 1
79+
m_EditorHideFlags: 0
80+
m_Script: {fileID: 11500000, guid: 0b7fac0fd4e39c24085140a05bff8d46, type: 3}
81+
m_Name: OutputURPTexture
82+
m_EditorClassIdentifier:
83+
m_Active: 1
84+
m_TextureType: 0

Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull/ForwardRenderer_MainlightShadowOutput.asset.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
using UnityEngine;
2+
using UnityEngine.Rendering;
3+
using UnityEngine.Rendering.Universal;
4+
using UnityEngine.Rendering.RenderGraphModule;
5+
using UnityEngine.Rendering.RenderGraphModule.Util;
6+
using System;
7+
8+
public class OutputURPTexture : ScriptableRendererFeature
9+
{
10+
[Serializable]
11+
enum TextureType
12+
{
13+
MainLightShadows,
14+
AddtionalLightShadows,
15+
}
16+
17+
class OutputURPTexturePass : ScriptableRenderPass
18+
{
19+
TextureType m_TextureType;
20+
public OutputURPTexturePass(TextureType textureType)
21+
{
22+
m_TextureType = textureType;
23+
}
24+
25+
public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData)
26+
{
27+
const string passName = "Output Texture Pass";
28+
UniversalResourceData resourceData = frameData.Get<UniversalResourceData>();
29+
TextureHandle sourceTexture;
30+
switch (m_TextureType)
31+
{
32+
case TextureType.MainLightShadows:
33+
sourceTexture = resourceData.mainShadowsTexture;
34+
break;
35+
case TextureType.AddtionalLightShadows:
36+
sourceTexture = resourceData.additionalShadowsTexture;
37+
break;
38+
default:
39+
throw new ArgumentException("Doesn't handle texture type please exstend function to include the type.", "m_TextureType");
40+
}
41+
RenderGraphUtils.AddBlitPass(renderGraph, sourceTexture, resourceData.activeColorTexture, Vector2.one, Vector2.zero, passName: passName);
42+
43+
}
44+
}
45+
46+
[SerializeField]
47+
TextureType m_TextureType;
48+
OutputURPTexturePass m_ScriptablePass;
49+
50+
public override void Create()
51+
{
52+
m_ScriptablePass = new OutputURPTexturePass(m_TextureType);
53+
m_ScriptablePass.renderPassEvent = RenderPassEvent.AfterRenderingSkybox;
54+
}
55+
56+
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
57+
{
58+
renderer.EnqueuePass(m_ScriptablePass);
59+
}
60+
}

Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull/OutputURPTexture.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using UnityEngine;
2+
3+
[ExecuteInEditMode]
4+
public class enableUseViewFrustumForShadowCasterCull : MonoBehaviour
5+
{
6+
[SerializeField]
7+
bool m_UseViewFrustumForShadowCasterCull;
8+
9+
Light m_light;
10+
void Start()
11+
{
12+
m_light = GetComponent<Light>();
13+
m_light.useViewFrustumForShadowCasterCull = m_UseViewFrustumForShadowCasterCull;
14+
}
15+
16+
void Update()
17+
{
18+
m_light.useViewFrustumForShadowCasterCull = m_UseViewFrustumForShadowCasterCull;
19+
}
20+
}

Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull/enableUseViewFrustumForShadowCasterCull.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)