Skip to content

Commit 13a1172

Browse files
adrien-de-tocquevilleEvergreen
authored andcommitted
[HDRP] Fix error when using light dimmer
Fix error in the console when using light dimmer
1 parent 97648d6 commit 13a1172

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,11 +1389,10 @@ void PreprocessVisibleLights(ScriptableRenderContext renderContext, CommandBuffe
13891389

13901390
if (hdCamera.visualSky.skyRenderer?.GetType() == typeof(PhysicallyBasedSkyRenderer))
13911391
{
1392-
// Lights with 0 intensity are culled by unity, but we still want to show them
1393-
// in the PBR sky, so we need to allocate space for the cookie
1392+
// Allocate space in the cookie atlas for PBR sky surface textures
13941393
foreach (var directional in lightEntities.directionalLights)
13951394
{
1396-
if (directional.legacyLight.intensity == 0.0f && directional.interactsWithSky)
1395+
if (directional.interactsWithSky)
13971396
m_TextureCaches.lightCookieManager.ReserveSpace(directional.surfaceTexture);
13981397
}
13991398
}
@@ -1773,8 +1772,6 @@ internal void ReserveCookieAtlasTexture(HDAdditionalLightData hdLightData, Light
17731772
{
17741773
case LightType.Directional:
17751774
{
1776-
if (hdLightData.interactsWithSky)
1777-
m_TextureCaches.lightCookieManager.ReserveSpace(hdLightData.surfaceTexture);
17781775
m_TextureCaches.lightCookieManager.ReserveSpace(light?.cookie);
17791776
break;
17801777
}

Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ public enum RenderingMode
168168

169169
/// <summary> Horizon tint. Does not affect the precomputation. </summary>
170170
[Tooltip("Specifies a color that HDRP uses to tint the sky at the horizon. Does not affect the precomputation.")]
171-
public ColorParameter horizonTint = new ColorParameter(Color.white, hdr: false, showAlpha: false, showEyeDropper: false);
171+
public ColorParameter horizonTint = new ColorParameter(Color.white, hdr: false, showAlpha: false, showEyeDropper: true);
172172

173173
/// <summary> Zenith tint. Does not affect the precomputation. </summary>
174174
[Tooltip("Specifies a color that HDRP uses to tint the point in the sky directly above the observer (the zenith). Does not affect the precomputation.")]
175-
public ColorParameter zenithTint = new ColorParameter(Color.white, hdr: false, showAlpha: false, showEyeDropper: false);
175+
public ColorParameter zenithTint = new ColorParameter(Color.white, hdr: false, showAlpha: false, showEyeDropper: true);
176176

177177
/// <summary> Horizon-zenith shift. Does not affect the precomputation. </summary>
178178
[Tooltip("Controls how HDRP blends between the Horizon Tint and Zenith Tint. Does not affect the precomputation.")]

Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ public void BindBuffers(MaterialPropertyBlock mpb)
311311

312312
static PrecomputationCache s_PrecomputationCache = new PrecomputationCache();
313313

314+
const int k_MaxCelestialBodies = 16;
314315
static GraphicsBuffer s_CelestialBodyBuffer;
315316
static CelestialBodyData[] s_CelestialBodyData;
316317
static int s_DataFrameUpdate = -1;
@@ -408,7 +409,6 @@ void UpdateCelestialBodyBuffer(CommandBuffer cmd, BuiltinSkyParameters builtinPa
408409
{
409410
if (s_CelestialBodyBuffer == null)
410411
{
411-
int k_MaxCelestialBodies = 16;
412412
int stride = System.Runtime.InteropServices.Marshal.SizeOf(typeof(CelestialBodyData));
413413
s_CelestialBodyBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Structured, k_MaxCelestialBodies, stride);
414414
s_CelestialBodyData = new CelestialBodyData[k_MaxCelestialBodies];
@@ -428,12 +428,14 @@ void UpdateCelestialBodyBuffer(CommandBuffer cmd, BuiltinSkyParameters builtinPa
428428
{
429429
FillCelestialBodyData(cmd, light, ref s_CelestialBodyData[lightCount++]);
430430
exposure = Mathf.Max(light.legacyLight.intensity * -light.transform.forward.y, exposure);
431+
if (lightCount >= k_MaxCelestialBodies) break;
431432
}
432433
}
433434

434435
uint bodyCount = lightCount;
435436
foreach (var light in directionalLights)
436437
{
438+
if (bodyCount >= k_MaxCelestialBodies) break;
437439
if (light.legacyLight.enabled && light.interactsWithSky && light.legacyLight.intensity == 0.0f)
438440
FillCelestialBodyData(cmd, light, ref s_CelestialBodyData[bodyCount++]);
439441
}

0 commit comments

Comments
 (0)