@@ -31,7 +31,7 @@ private static void Execute(RasterGraphContext context, PassData passData)
3131 RendererLighting . SetLightShaderGlobals ( cmd , passData . lightBlendStyles , passData . blendStyleIndices ) ;
3232
3333#if UNITY_EDITOR
34- if ( passData . isLitView )
34+ if ( passData . isLightingActive )
3535#endif
3636 {
3737 if ( passData . layerUseLights )
@@ -79,7 +79,7 @@ class PassData
7979 internal bool activeDebugHandler ;
8080
8181#if UNITY_EDITOR
82- internal bool isLitView ; // Required for prefab view and preview camera
82+ internal bool isLightingActive ; // Required for prefab view and preview camera
8383#endif
8484 }
8585
@@ -93,35 +93,28 @@ public void Render(RenderGraph graph, ContextContainer frameData, int batchIndex
9393 Renderer2DData rendererData = frameData . Get < Universal2DRenderingData > ( ) . renderingData ;
9494 var layerBatch = frameData . Get < Universal2DRenderingData > ( ) . layerBatches [ batchIndex ] ;
9595
96- bool isLitView = true ;
96+ DebugHandler debugHandler = GetActiveDebugHandler ( cameraData ) ;
97+ var isLightingActive = debugHandler ? . IsLightingActive ?? true ;
9798
9899#if UNITY_EDITOR
99100 // Early out for prefabs
100101 if ( cameraData . isSceneViewCamera && UnityEditor . SceneView . currentDrawingSceneView != null )
101- isLitView = UnityEditor . SceneView . currentDrawingSceneView . sceneLighting ;
102-
103- // Early out for preview camera
104- if ( cameraData . cameraType == CameraType . Preview )
105- isLitView = false ;
106-
107- DebugHandler debugHandler = GetActiveDebugHandler ( cameraData ) ;
108- if ( debugHandler != null )
109- isLitView = debugHandler . IsLightingActive ;
102+ isLightingActive = UnityEditor . SceneView . currentDrawingSceneView . sceneLighting ;
110103#endif
111104
112105 // Preset global light textures for first batch
113106 if ( batchIndex == 0 )
114107 {
115108 using ( var builder = graph . AddRasterRenderPass < SetGlobalPassData > ( k_SetLightBlendTexture , out var passData , m_SetLightBlendTextureProfilingSampler ) )
116109 {
117- if ( layerBatch . lightStats . useLights && isLitView )
110+ if ( layerBatch . lightStats . useLights && isLightingActive )
118111 {
119112 passData . lightTextures = universal2DResourceData . lightTextures [ batchIndex ] ;
120113 for ( var i = 0 ; i < passData . lightTextures . Length ; i ++ )
121114 builder . UseTexture ( passData . lightTextures [ i ] ) ;
122115 }
123116
124- SetGlobalLightTextures ( graph , builder , frameData , batchIndex , isLitView ) ;
117+ SetGlobalLightTextures ( graph , builder , frameData , batchIndex , isLightingActive ) ;
125118
126119 builder . AllowGlobalStateModification ( true ) ;
127120
@@ -143,7 +136,7 @@ public void Render(RenderGraph graph, ContextContainer frameData, int batchIndex
143136 passData . isSceneLit = rendererData . lightCullResult . IsSceneLit ( ) ;
144137 passData . layerUseLights = layerBatch . lightStats . useLights ;
145138#if UNITY_EDITOR
146- passData . isLitView = isLitView ;
139+ passData . isLightingActive = isLightingActive ;
147140#endif
148141
149142 var drawSettings = CreateDrawingSettings ( k_ShaderTags , renderingData , cameraData , lightData , SortingCriteria . CommonTransparent ) ;
@@ -168,7 +161,7 @@ public void Render(RenderGraph graph, ContextContainer frameData, int batchIndex
168161 builder . UseRendererList ( passData . rendererList ) ;
169162 }
170163
171- if ( passData . layerUseLights && isLitView )
164+ if ( passData . layerUseLights && isLightingActive )
172165 {
173166 passData . lightTextures = universal2DResourceData . lightTextures [ batchIndex ] ;
174167 for ( var i = 0 ; i < passData . lightTextures . Length ; i ++ )
@@ -189,7 +182,7 @@ public void Render(RenderGraph graph, ContextContainer frameData, int batchIndex
189182 // Post set global light textures for next renderer pass
190183 var nextBatch = batchIndex + 1 ;
191184 if ( nextBatch < universal2DResourceData . lightTextures . Length )
192- SetGlobalLightTextures ( graph , builder , frameData , nextBatch , isLitView ) ;
185+ SetGlobalLightTextures ( graph , builder , frameData , nextBatch , isLightingActive ) ;
193186
194187 builder . SetRenderFunc ( static ( PassData data , RasterGraphContext context ) =>
195188 {
@@ -198,13 +191,13 @@ public void Render(RenderGraph graph, ContextContainer frameData, int batchIndex
198191 }
199192 }
200193
201- void SetGlobalLightTextures ( RenderGraph graph , IRasterRenderGraphBuilder builder , ContextContainer frameData , int batchIndex , bool isLitView )
194+ void SetGlobalLightTextures ( RenderGraph graph , IRasterRenderGraphBuilder builder , ContextContainer frameData , int batchIndex , bool isLightingActive )
202195 {
203196 Renderer2DData rendererData = frameData . Get < Universal2DRenderingData > ( ) . renderingData ;
204197 var layerBatch = frameData . Get < Universal2DRenderingData > ( ) . layerBatches [ batchIndex ] ;
205198 var lightTextures = frameData . Get < Universal2DResourceData > ( ) . lightTextures [ batchIndex ] ;
206199
207- if ( isLitView )
200+ if ( isLightingActive )
208201 {
209202 if ( layerBatch . lightStats . useLights )
210203 {
0 commit comments