Skip to content

Commit da09cf2

Browse files
pmavridisEvergreen
authored andcommitted
Better inform users about light limits in URP
We now inform users about light limits in URP when running in the editor. https://jira.unity3d.com/browse/UUM-56213
1 parent 820745d commit da09cf2

File tree

1 file changed

+0
-12
lines changed

1 file changed

+0
-12
lines changed

Packages/com.unity.render-pipelines.universal/Runtime/Passes/AdditionalLightsShadowCasterPass.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,11 @@ internal static float GetPointLightShadowFrustumFovBiasInDegrees(int shadowSlice
172172
// We can see that the guard angle is roughly proportional to the inverse of resolution https://docs.google.com/spreadsheets/d/1QrIZJn18LxVKq2-K1XS4EFRZcZdZOJTTKKhDN8Z1b_s
173173
if (shadowSliceResolution <= ShadowUtils.kMinimumPunctualLightHardShadowResolution)
174174
{
175-
#if DEVELOPMENT_BUILD
176175
if (!m_IssuedMessageAboutPointLightHardShadowResolutionTooSmall)
177176
{
178177
Debug.LogWarning("Too many additional punctual lights shadows, increase shadow atlas size or remove some shadowed lights");
179178
m_IssuedMessageAboutPointLightHardShadowResolutionTooSmall = true; // Only output this once per shadow requests configuration
180179
}
181-
#endif
182180
}
183181
else if (shadowSliceResolution <= 16)
184182
fovBias = 43.0f;
@@ -201,14 +199,12 @@ internal static float GetPointLightShadowFrustumFovBiasInDegrees(int shadowSlice
201199
{
202200
if (shadowSliceResolution <= ShadowUtils.kMinimumPunctualLightSoftShadowResolution)
203201
{
204-
#if DEVELOPMENT_BUILD
205202
if (!m_IssuedMessageAboutPointLightSoftShadowResolutionTooSmall)
206203
{
207204
Debug.LogWarning("Too many additional punctual lights shadows to use Soft Shadows. Increase shadow atlas size, remove some shadowed lights or use Hard Shadows.");
208205
// With such small resolutions no fovBias can give good visual results
209206
m_IssuedMessageAboutPointLightSoftShadowResolutionTooSmall = true; // Only output this once per shadow requests configuration
210207
}
211-
#endif
212208
}
213209
else if (shadowSliceResolution <= 32)
214210
fovBias += 9.35f;
@@ -232,14 +228,12 @@ internal static float GetPointLightShadowFrustumFovBiasInDegrees(int shadowSlice
232228
return fovBias;
233229
}
234230

235-
#if DEVELOPMENT_BUILD
236231
private bool m_IssuedMessageAboutShadowSlicesTooMany = false;
237232
private bool m_IssuedMessageAboutShadowMapsRescale = false;
238233
private bool m_IssuedMessageAboutShadowMapsTooBig = false;
239234
private bool m_IssuedMessageAboutRemovedShadowSlices = false;
240235
private static bool m_IssuedMessageAboutPointLightHardShadowResolutionTooSmall = false;
241236
private static bool m_IssuedMessageAboutPointLightSoftShadowResolutionTooSmall = false;
242-
#endif
243237

244238
Dictionary<int, ulong> m_ShadowRequestsHashes = new Dictionary<int, ulong>(); // used to keep track of changes in the shadow requests and shadow atlas configuration (per camera)
245239

@@ -342,7 +336,6 @@ public bool Setup(UniversalRenderingData renderingData, UniversalCameraData came
342336
var visibleLights = lightData.visibleLights;
343337
ref AdditionalLightsShadowAtlasLayout atlasLayout = ref shadowData.shadowAtlasLayout;
344338

345-
#if DEVELOPMENT_BUILD
346339
// Check changes in the shadow requests and shadow atlas configuration - compute shadow request/configuration hash
347340
if (!cameraData.isPreviewCamera)
348341
{
@@ -362,7 +355,6 @@ public bool Setup(UniversalRenderingData renderingData, UniversalCameraData came
362355
m_IssuedMessageAboutRemovedShadowSlices = false;
363356
}
364357
}
365-
#endif
366358

367359
if (m_VisibleLightIndexToAdditionalLightIndex.Length < visibleLights.Length)
368360
{
@@ -386,7 +378,6 @@ public bool Setup(UniversalRenderingData renderingData, UniversalCameraData came
386378
bool hasTooManyShadowMaps = atlasLayout.HasTooManyShadowMaps();
387379
int atlasSize = atlasLayout.GetAtlasSize();
388380

389-
#if DEVELOPMENT_BUILD
390381
if (totalShadowSlicesCount < totalShadowResolutionRequestCount)
391382
{
392383
if (!m_IssuedMessageAboutRemovedShadowSlices)
@@ -407,7 +398,6 @@ public bool Setup(UniversalRenderingData renderingData, UniversalCameraData came
407398
Debug.Log($"Reduced additional punctual light shadows resolution by {shadowSlicesScaleFactor} to make {totalShadowSlicesCount} shadow maps fit in the {atlasSize}x{atlasSize} shadow atlas. To avoid this, increase shadow atlas size, decrease big shadow resolutions, or reduce the number of shadow maps active in the same frame");
408399
m_IssuedMessageAboutShadowMapsRescale = true; // Only output this once per shadow requests configuration
409400
}
410-
#endif
411401

412402
if (m_AdditionalLightsShadowSlices == null || m_AdditionalLightsShadowSlices.Length < totalShadowSlicesCount)
413403
m_AdditionalLightsShadowSlices = new ShadowSliceData[totalShadowSlicesCount];
@@ -450,14 +440,12 @@ public bool Setup(UniversalRenderingData renderingData, UniversalCameraData came
450440

451441
if ((m_ShadowSliceToAdditionalLightIndex.Count + perLightShadowSlicesCount) > totalShadowSlicesCount && ShadowUtils.IsValidShadowCastingLight(lightData, visibleLightIndex))
452442
{
453-
#if DEVELOPMENT_BUILD
454443
if (!m_IssuedMessageAboutShadowSlicesTooMany)
455444
{
456445
// This case can especially happen in Deferred, where there can be a high number of visibleLights
457446
Debug.Log($"There are too many shadowed additional punctual lights active at the same time, URP will not render all the shadows. To ensure all shadows are rendered, reduce the number of shadowed additional lights in the scene ; make sure they are not active at the same time ; or replace point lights by spot lights (spot lights use less shadow maps than point lights).");
458447
m_IssuedMessageAboutShadowSlicesTooMany = true; // Only output this once
459448
}
460-
#endif
461449
break;
462450
}
463451

0 commit comments

Comments
 (0)