@@ -27,9 +27,12 @@ internal static class ShadowRendering
27
27
28
28
private static RenderTargetHandle [ ] m_RenderTargets = null ;
29
29
private static RenderTargetIdentifier [ ] m_LightInputTextures = null ;
30
+
31
+ private static readonly Color k_ColorNone = new Color ( 0 , 0 , 0 , 0 ) ;
30
32
private static readonly Color [ ] k_ColorLookup = new Color [ 4 ] { new Color ( 0 , 0 , 0 , 1 ) , new Color ( 0 , 0 , 1 , 0 ) , new Color ( 0 , 1 , 0 , 0 ) , new Color ( 1 , 0 , 0 , 0 ) } ;
31
33
private static readonly ProfilingSampler [ ] m_ProfilingSamplerShadowColorsLookup = new ProfilingSampler [ 4 ] { m_ProfilingSamplerShadowsA , m_ProfilingSamplerShadowsB , m_ProfilingSamplerShadowsG , m_ProfilingSamplerShadowsR } ;
32
34
35
+
33
36
public static uint maxTextureCount { get ; private set ; }
34
37
35
38
public static void InitializeBudget ( uint maxTextureCount )
@@ -49,9 +52,7 @@ public static void InitializeBudget(uint maxTextureCount)
49
52
}
50
53
51
54
if ( m_LightInputTextures == null || m_LightInputTextures . Length != maxTextureCount )
52
- {
53
55
m_LightInputTextures = new RenderTargetIdentifier [ maxTextureCount ] ;
54
- }
55
56
}
56
57
57
58
private static Material [ ] CreateMaterials ( Shader shader , int pass = 0 )
@@ -135,15 +136,13 @@ public static bool PrerenderShadows(IRenderPass2D pass, RenderingData renderingD
135
136
var textureIndex = shadowIndex / 4 ;
136
137
137
138
if ( colorChannel == 0 )
138
- ShadowRendering . CreateShadowRenderTexture ( pass , renderingData , cmdBuffer , textureIndex ) ;
139
+ CreateShadowRenderTexture ( pass , renderingData , cmdBuffer , textureIndex ) ;
139
140
140
141
bool hadShadowsToRender = RenderShadows ( pass , renderingData , cmdBuffer , layerToRender , light , shadowIntensity , m_RenderTargets [ textureIndex ] . Identifier ( ) , colorChannel ) ;
141
142
142
143
// Render the shadows for this light
143
- if ( RenderShadows ( pass , renderingData , cmdBuffer , layerToRender , light , shadowIntensity , m_RenderTargets [ textureIndex ] . Identifier ( ) , colorChannel ) )
144
+ if ( hadShadowsToRender )
144
145
m_LightInputTextures [ textureIndex ] = m_RenderTargets [ textureIndex ] . Identifier ( ) ;
145
- else
146
- m_LightInputTextures [ textureIndex ] = Texture2D . blackTexture ;
147
146
148
147
return hadShadowsToRender ;
149
148
}
@@ -161,6 +160,7 @@ public static void SetGlobalShadowTexture(CommandBuffer cmdBuffer, Light2D light
161
160
162
161
public static void DisableGlobalShadowTexture ( CommandBuffer cmdBuffer )
163
162
{
163
+ cmdBuffer . SetGlobalColor ( k_ShadowColorMaskID , k_ColorNone ) ;
164
164
cmdBuffer . SetGlobalFloat ( k_ShadowIntensityID , 1 ) ;
165
165
cmdBuffer . SetGlobalFloat ( k_ShadowVolumeIntensityID , 1 ) ;
166
166
}
0 commit comments