From d964f71ea4143c7cdd50a27e5327e55790922465 Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Thu, 3 Dec 2020 14:57:53 +0100 Subject: [PATCH 1/6] Fix first frame exposure, depth pyramid / AO --- .../Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs | 4 +--- .../Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs index d058e1dd5f7..894d22e41db 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs @@ -317,9 +317,7 @@ TextureHandle DynamicExposurePass(RenderGraph renderGraph, HDCamera hdCamera, Te { passData.source = builder.ReadTexture(source); passData.parameters = PrepareApplyExposureParameters(hdCamera); - RTHandle prevExp; - GrabExposureHistoryTextures(hdCamera, out prevExp, out _); - passData.prevExposure = builder.ReadTexture(renderGraph.ImportTexture(prevExp)); + passData.prevExposure = renderGraph.ImportTexture(GetPreviousExposureTexture(hdCamera)); TextureHandle dest = GetPostprocessOutputHandle(renderGraph, "Apply Exposure Destination"); passData.destination = builder.WriteTexture(dest);; diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs index fd45b34dacd..a4b36c0327f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs @@ -52,6 +52,12 @@ bool NeedClearGBuffer() HDUtils.PackedMipChainInfo GetDepthBufferMipChainInfo() { + // Initialize if nececcary + if (m_DepthBufferMipChainInfo.textureSize == Vector2Int.zero) + { + m_DepthBufferMipChainInfo.ComputePackedMipChainInfo(new Vector2Int(RTHandles.maxWidth, RTHandles.maxHeight)); + } + return m_DepthBufferMipChainInfo; } From 1ec63b83ad930ccf5a7f1b4343fafd2e5b7cf61f Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Thu, 3 Dec 2020 15:04:00 +0100 Subject: [PATCH 2/6] Update 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 7fc7a8cbfc7..bed55aadf8a 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed - Fixed probe volumes debug views. +- Fixed issues with first frame rendering when RenderGraph is used (auto exposure, AO) ### Changed - Removed the material pass probe volumes evaluation mode. From d98ca8530342b5cd7fc13700c70e0c851061a50c Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Thu, 3 Dec 2020 15:08:48 +0100 Subject: [PATCH 3/6] Comment --- .../Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs index a4b36c0327f..3117daebb67 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs @@ -52,7 +52,7 @@ bool NeedClearGBuffer() HDUtils.PackedMipChainInfo GetDepthBufferMipChainInfo() { - // Initialize if nececcary + // Initialize the MipChainInfo if nececcary. This will be necessary when rendering the first frame. if (m_DepthBufferMipChainInfo.textureSize == Vector2Int.zero) { m_DepthBufferMipChainInfo.ComputePackedMipChainInfo(new Vector2Int(RTHandles.maxWidth, RTHandles.maxHeight)); From 05ed67d9a5b1230f3332f288af23c2a191c0437a Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Thu, 3 Dec 2020 15:35:14 +0100 Subject: [PATCH 4/6] Typo --- .../Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs index 3117daebb67..07426bc72cf 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs @@ -52,7 +52,7 @@ bool NeedClearGBuffer() HDUtils.PackedMipChainInfo GetDepthBufferMipChainInfo() { - // Initialize the MipChainInfo if nececcary. This will be necessary when rendering the first frame. + // Initialize the MipChainInfo if necessary. This will be necessary when rendering the first frame. if (m_DepthBufferMipChainInfo.textureSize == Vector2Int.zero) { m_DepthBufferMipChainInfo.ComputePackedMipChainInfo(new Vector2Int(RTHandles.maxWidth, RTHandles.maxHeight)); From 27a9c0faaecf4796b3e61e3bd32ed0bb26e1913e Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Thu, 3 Dec 2020 16:26:18 +0100 Subject: [PATCH 5/6] Add missing RenderGraphBuilder.ReadTexture call --- .../Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs index 894d22e41db..f689421f77b 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs @@ -317,7 +317,7 @@ TextureHandle DynamicExposurePass(RenderGraph renderGraph, HDCamera hdCamera, Te { passData.source = builder.ReadTexture(source); passData.parameters = PrepareApplyExposureParameters(hdCamera); - passData.prevExposure = renderGraph.ImportTexture(GetPreviousExposureTexture(hdCamera)); + passData.prevExposure = builder.ReadTexture(renderGraph.ImportTexture(GetPreviousExposureTexture(hdCamera))); TextureHandle dest = GetPostprocessOutputHandle(renderGraph, "Apply Exposure Destination"); passData.destination = builder.WriteTexture(dest);; From 2854c000feda16b726ae7fb45fe22575e2b56748 Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Thu, 3 Dec 2020 16:55:43 +0100 Subject: [PATCH 6/6] Move ComputePackedMipChainInfo at the beginning of ExecuteWithRenderGraph --- .../Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs | 6 ------ .../Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs index 07426bc72cf..fd45b34dacd 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs @@ -52,12 +52,6 @@ bool NeedClearGBuffer() HDUtils.PackedMipChainInfo GetDepthBufferMipChainInfo() { - // Initialize the MipChainInfo if necessary. This will be necessary when rendering the first frame. - if (m_DepthBufferMipChainInfo.textureSize == Vector2Int.zero) - { - m_DepthBufferMipChainInfo.ComputePackedMipChainInfo(new Vector2Int(RTHandles.maxWidth, RTHandles.maxHeight)); - } - return m_DepthBufferMipChainInfo; } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs index 72365664cbc..d975226d58d 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs @@ -34,6 +34,9 @@ void ExecuteWithRenderGraph(RenderRequest renderRequest, m_RenderGraph.Begin(renderGraphParams); + // We need to initalize the MipChainInfo here, so it will be available to any render graph pass that wants to use it during setup + m_DepthBufferMipChainInfo.ComputePackedMipChainInfo(new Vector2Int(hdCamera.actualWidth, hdCamera.actualHeight)); + #if UNITY_EDITOR var showGizmos = camera.cameraType == CameraType.Game || camera.cameraType == CameraType.SceneView;