From 3a5ccc80a3c2b9efab2253139ae2a7f528e54fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Thu, 14 May 2020 12:58:35 +0200 Subject: [PATCH 1/2] Fix the show cookie atlas debug mode not displaying correctly --- .../Runtime/Debug/DebugDisplay.cs | 4 ++-- .../Runtime/Lighting/LightLoop/LightLoop.cs | 15 ++++++++------- .../Runtime/RenderPipeline/HDRenderPipeline.cs | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs index 34bc9598dba..7a3e7461d07 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs @@ -1093,7 +1093,7 @@ void RegisterLightingDebug() children = { new DebugUI.UIntField { displayName = "Mip Level", getter = () => data.lightingDebugSettings.cookieAtlasMipLevel, setter = value => data.lightingDebugSettings.cookieAtlasMipLevel = value, min = () => 0, max = () => (uint)(RenderPipelineManager.currentPipeline as HDRenderPipeline).GetCookieAtlasMipCount()}, - new DebugUI.Button { displayName = "Reset Cookie Atlas", action = () => data.lightingDebugSettings.clearCookieAtlas = true} + new DebugUI.BoolField { displayName = "Clear Cookie Atlas", getter = () => data.lightingDebugSettings.clearCookieAtlas, setter = value => data.lightingDebugSettings.clearCookieAtlas = value} } }); } @@ -1118,7 +1118,7 @@ void RegisterLightingDebug() children = { new DebugUI.UIntField { displayName = "Mip Level", getter = () => data.lightingDebugSettings.planarReflectionProbeMipLevel, setter = value => data.lightingDebugSettings.planarReflectionProbeMipLevel = value, min = () => 0, max = () => (uint)(RenderPipelineManager.currentPipeline as HDRenderPipeline).GetPlanarReflectionProbeMipCount()}, - new DebugUI.Button { displayName = "Reset Planar Atlas", action = () => data.lightingDebugSettings.clearPlanarReflectionProbeAtlas = true }, + new DebugUI.BoolField { displayName = "Clear Planar Atlas", getter = () => data.lightingDebugSettings.clearPlanarReflectionProbeAtlas, setter = value => data.lightingDebugSettings.clearPlanarReflectionProbeAtlas = value}, } }); } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs index 71ab4ad5a9e..644fcd0d80c 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs @@ -997,7 +997,7 @@ void LightLoopNewRender() m_ScreenSpaceShadowsUnion.Clear(); } - void LightLoopNewFrame(HDCamera hdCamera) + void LightLoopNewFrame(CommandBuffer cmd, HDCamera hdCamera) { var frameSettings = hdCamera.frameSettings; @@ -1015,6 +1015,13 @@ void LightLoopNewFrame(HDCamera hdCamera) { m_WorldToViewMatrices.Add(GetWorldToViewMatrix(hdCamera, viewIndex)); } + + // Clear the cookie atlas if needed at the beginning of the frame. + if (m_DebugDisplaySettings.data.lightingDebugSettings.clearCookieAtlas) + { + m_TextureCaches.lightCookieManager.ResetAllocator(); + m_TextureCaches.lightCookieManager.ClearAtlasTexture(cmd); + } } void LightLoopReleaseResolutionDependentBuffers() @@ -4062,12 +4069,6 @@ static void RenderLightLoopDebugOverlay(in DebugParameters debugParameters, Comm } } - if (lightingDebug.clearCookieAtlas) - { - parameters.cookieManager.ResetAllocator(); - parameters.cookieManager.ClearAtlasTexture(cmd); - } - if (lightingDebug.displayCookieAtlas) { using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.DisplayCookieAtlas))) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index d9fed5800ad..e96e3f45bf6 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -2068,7 +2068,7 @@ AOVRequestData aovRequest // Do anything we need to do upon a new frame. // The NewFrame must be after the VolumeManager update and before Resize because it uses properties set in NewFrame - LightLoopNewFrame(hdCamera); + LightLoopNewFrame(cmd, hdCamera); // Apparently scissor states can leak from editor code. As it is not used currently in HDRP (apart from VR). We disable scissor at the beginning of the frame. cmd.DisableScissorRect(); From 51a44a0fe990cb78eb48f94b8f2a446643e202c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Thu, 14 May 2020 13:00:28 +0200 Subject: [PATCH 2/2] Updated changelog --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 1da9383b377..0e0b9006c43 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -596,6 +596,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed shader graphs not casting semi-transparent and color shadows (case 1242617) - Fixed thin refraction mode not working properly. - Fixed assert on tests caused by probe culling results being requested when culling did not happen. (case 1246169) +- Fixed the show cookie atlas debug mode not displaying correctly when enabling the clear cookie atlas option. ### Changed - Improve MIP selection for decals on Transparents