@@ -11,6 +11,7 @@ public class LowEndMobilePipeline : RenderPipeline
1111
1212 private static readonly int kMaxCascades = 4 ;
1313 private static readonly int kMaxLights = 8 ;
14+ private int m_ShadowCasterCascadesCount = kMaxCascades ;
1415 private int m_ShadowMapProperty ;
1516 private RenderTargetIdentifier m_ShadowMapRTID ;
1617 private int m_DepthBufferBits = 24 ;
@@ -65,7 +66,7 @@ public override void Render(ScriptableRenderContext context, Camera[] cameras)
6566 // Setup light and shadow shader constants
6667 SetupLightShaderVariables ( cull . visibleLights , context ) ;
6768 if ( shadowsRendered )
68- SetupShadowShaderVariables ( context , m_ShadowSettings . directionalLightCascadeCount ) ;
69+ SetupShadowShaderVariables ( context , m_ShadowCasterCascadesCount ) ;
6970
7071 // Render Opaques
7172 var settings = new DrawRendererSettings ( cull , camera , m_ForwardBasePassName ) ;
@@ -185,7 +186,7 @@ private void SetupLightShaderVariables(VisibleLight[] lights, ScriptableRenderCo
185186
186187 private bool RenderShadows ( CullResults cullResults , ScriptableRenderContext context )
187188 {
188- int cascadeCount = m_ShadowSettings . directionalLightCascadeCount ;
189+ m_ShadowCasterCascadesCount = m_ShadowSettings . directionalLightCascadeCount ;
189190
190191 VisibleLight [ ] lights = cullResults . visibleLights ;
191192 int lightCount = lights . Length ;
@@ -199,10 +200,10 @@ private bool RenderShadows(CullResults cullResults, ScriptableRenderContext cont
199200 {
200201 lightIndex = i ;
201202 if ( lights [ i ] . lightType == LightType . Spot )
202- cascadeCount = 1 ;
203+ m_ShadowCasterCascadesCount = 1 ;
203204
204205 shadowResolution = GetMaxTileResolutionInAtlas ( m_ShadowSettings . shadowAtlasWidth ,
205- m_ShadowSettings . shadowAtlasHeight , cascadeCount ) ;
206+ m_ShadowSettings . shadowAtlasHeight , m_ShadowCasterCascadesCount ) ;
206207 break ;
207208 }
208209 }
@@ -245,10 +246,10 @@ private bool RenderShadows(CullResults cullResults, ScriptableRenderContext cont
245246 }
246247 else if ( lights [ lightIndex ] . lightType == LightType . Directional )
247248 {
248- for ( int cascadeIdx = 0 ; cascadeIdx < cascadeCount ; ++ cascadeIdx )
249+ for ( int cascadeIdx = 0 ; cascadeIdx < m_ShadowCasterCascadesCount ; ++ cascadeIdx )
249250 {
250251 needRendering = cullResults . ComputeDirectionalShadowMatricesAndCullingPrimitives ( lightIndex ,
251- cascadeIdx , cascadeCount , splitRatio , shadowResolution , shadowNearPlane , out view , out proj ,
252+ cascadeIdx , m_ShadowCasterCascadesCount , splitRatio , shadowResolution , shadowNearPlane , out view , out proj ,
252253 out settings . splitData ) ;
253254
254255 m_DirectionalShadowSplitDistances [ cascadeIdx ] = settings . splitData . cullingSphere ;
@@ -371,7 +372,7 @@ void SetShaderKeywords(CommandBuffer cmd)
371372 else
372373 cmd . DisableShaderKeyword ( "_VERTEX_LIGHTS" ) ;
373374
374- if ( m_Asset . CascadeCount == 1 )
375+ if ( m_ShadowCasterCascadesCount == 1 )
375376 cmd . DisableShaderKeyword ( "_SHADOW_CASCADES" ) ;
376377 else
377378 cmd . EnableShaderKeyword ( "_SHADOW_CASCADES" ) ;
0 commit comments