@@ -39,7 +39,7 @@ private static void Execute(RasterGraphContext context, PassData passData)
3939 RendererLighting . SetLightShaderGlobals ( cmd , passData . lightBlendStyles , passData . blendStyleIndices ) ;
4040
4141#if UNITY_EDITOR
42- if ( passData . isLitView )
42+ if ( passData . isLightingActive )
4343#endif
4444 {
4545 if ( passData . layerUseLights )
@@ -87,7 +87,7 @@ class PassData
8787 internal bool activeDebugHandler ;
8888
8989#if UNITY_EDITOR
90- internal bool isLitView ; // Required for prefab view and preview camera
90+ internal bool isLightingActive ; // Required for prefab view and preview camera
9191#endif
9292 }
9393
@@ -100,35 +100,23 @@ public void Render(RenderGraph graph, ContextContainer frameData, Renderer2DData
100100 CommonResourceData commonResourceData = frameData . Get < CommonResourceData > ( ) ;
101101
102102 var layerBatch = layerBatches [ batchIndex ] ;
103- bool isLitView = true ;
104103
105- #if UNITY_EDITOR
106- // Early out for prefabs
107- if ( cameraData . isSceneViewCamera && UnityEditor . SceneView . currentDrawingSceneView != null )
108- isLitView = UnityEditor . SceneView . currentDrawingSceneView . sceneLighting ;
109-
110- // Early out for preview camera
111- if ( cameraData . cameraType == CameraType . Preview )
112- isLitView = false ;
113-
114- DebugHandler debugHandler = GetActiveDebugHandler ( cameraData ) ;
115- if ( debugHandler != null )
116- isLitView = debugHandler . IsLightingActive ;
117- #endif
104+ // Check for lighting in scene/prefab/preview camera
105+ var isLightingActive = Renderer2D . s_IsLightingActive ;
118106
119107 // Preset global light textures for first batch
120108 if ( batchIndex == 0 )
121109 {
122110 using ( var builder = graph . AddRasterRenderPass < SetGlobalPassData > ( k_SetLightBlendTexture , out var passData , m_SetLightBlendTextureProfilingSampler ) )
123111 {
124- if ( layerBatch . lightStats . useLights && isLitView )
112+ if ( layerBatch . lightStats . useLights && isLightingActive )
125113 {
126114 passData . lightTextures = universal2DResourceData . lightTextures [ batchIndex ] ;
127115 for ( var i = 0 ; i < passData . lightTextures . Length ; i ++ )
128116 builder . UseTexture ( passData . lightTextures [ i ] ) ;
129117 }
130118
131- SetGlobalLightTextures ( graph , builder , passData . lightTextures , ref layerBatch , rendererData , isLitView ) ;
119+ SetGlobalLightTextures ( graph , builder , passData . lightTextures , ref layerBatch , rendererData , isLightingActive ) ;
132120
133121 builder . AllowGlobalStateModification ( true ) ;
134122
@@ -147,7 +135,7 @@ public void Render(RenderGraph graph, ContextContainer frameData, Renderer2DData
147135 passData . isSceneLit = rendererData . lightCullResult . IsSceneLit ( ) ;
148136 passData . layerUseLights = layerBatch . lightStats . useLights ;
149137#if UNITY_EDITOR
150- passData . isLitView = isLitView ;
138+ passData . isLightingActive = isLightingActive ;
151139#endif
152140
153141 var drawSettings = CreateDrawingSettings ( k_ShaderTags , renderingData , cameraData , lightData , SortingCriteria . CommonTransparent ) ;
@@ -172,7 +160,7 @@ public void Render(RenderGraph graph, ContextContainer frameData, Renderer2DData
172160 builder . UseRendererList ( passData . rendererList ) ;
173161 }
174162
175- if ( passData . layerUseLights && isLitView )
163+ if ( passData . layerUseLights && isLightingActive )
176164 {
177165 passData . lightTextures = universal2DResourceData . lightTextures [ batchIndex ] ;
178166 for ( var i = 0 ; i < passData . lightTextures . Length ; i ++ )
@@ -193,7 +181,7 @@ public void Render(RenderGraph graph, ContextContainer frameData, Renderer2DData
193181 // Post set global light textures for next renderer pass
194182 var nextBatch = batchIndex + 1 ;
195183 if ( nextBatch < universal2DResourceData . lightTextures . Length )
196- SetGlobalLightTextures ( graph , builder , universal2DResourceData . lightTextures [ nextBatch ] , ref layerBatches [ nextBatch ] , rendererData , isLitView ) ;
184+ SetGlobalLightTextures ( graph , builder , universal2DResourceData . lightTextures [ nextBatch ] , ref layerBatches [ nextBatch ] , rendererData , isLightingActive ) ;
197185
198186 builder . SetRenderFunc ( ( PassData data , RasterGraphContext context ) =>
199187 {
@@ -202,9 +190,9 @@ public void Render(RenderGraph graph, ContextContainer frameData, Renderer2DData
202190 }
203191 }
204192
205- void SetGlobalLightTextures ( RenderGraph graph , IRasterRenderGraphBuilder builder , TextureHandle [ ] lightTextures , ref LayerBatch layerBatch , Renderer2DData rendererData , bool isLitView )
193+ void SetGlobalLightTextures ( RenderGraph graph , IRasterRenderGraphBuilder builder , TextureHandle [ ] lightTextures , ref LayerBatch layerBatch , Renderer2DData rendererData , bool isLightingActive )
206194 {
207- if ( isLitView )
195+ if ( isLightingActive )
208196 {
209197 if ( layerBatch . lightStats . useLights )
210198 {
0 commit comments