From 409eea7ccc404b882b1ab0bda8d6c2d3184a69c9 Mon Sep 17 00:00:00 2001 From: Emmanuel Turquin Date: Wed, 3 Nov 2021 19:15:22 +0100 Subject: [PATCH 1/2] Made a few methods related to path tracing and accumulation public. --- .../Accumulation/SubFrameManager.cs | 14 +++++++++++++- .../RenderPipeline/PathTracing/PathTracing.cs | 16 +++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Accumulation/SubFrameManager.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Accumulation/SubFrameManager.cs index aed917fc501..5636d8a3862 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Accumulation/SubFrameManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Accumulation/SubFrameManager.cs @@ -153,7 +153,7 @@ internal void PrepareNewSubFrame() foreach (int camID in m_CameraCache.Keys.ToList()) maxIteration = Math.Max(maxIteration, GetCameraData(camID).currentIteration); - if (maxIteration == m_AccumulationSamples) + if (maxIteration >= m_AccumulationSamples) { Reset(); } @@ -264,6 +264,18 @@ public void PrepareNewSubFrame() m_SubFrameManager.PrepareNewSubFrame(); } + /// + /// Checks if the multi-frame accumulation is completed for a given camera. + /// + /// Camera for which the accumulation status is checked. + /// true if the accumulation is completed, false otherwise. + public bool IsFrameCompleted(HDCamera hdCamera) + { + int camID = hdCamera.camera.GetInstanceID(); + CameraData camData = m_SubFrameManager.GetCameraData(camID); + return camData.currentIteration >= m_SubFrameManager.subFrameCount; + } + class RenderAccumulationPassData { public ComputeShader accumulationCS; diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs index 90c6372674e..5ba14611f88 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs @@ -112,12 +112,26 @@ void ReleasePathTracing() #endif // UNITY_EDITOR } - internal void ResetPathTracing() + /// + /// Resets path tracing accumulation for all cameras. + /// + public void ResetPathTracing() { m_RenderSky = true; m_SubFrameManager.Reset(); } + /// + /// Resets path tracing accumulation for a specific camera. + /// + /// Camera for which the accumulation is reset. + public void ResetPathTracing(HDCamera hdCamera) + { + int camID = hdCamera.camera.GetInstanceID(); + CameraData camData = m_SubFrameManager.GetCameraData(camID); + ResetPathTracing(camID, camData); + } + internal CameraData ResetPathTracing(int camID, CameraData camData) { m_RenderSky = true; From 7a208cb5f467e2e9ce308a1dd3dd7e2e03663c93 Mon Sep 17 00:00:00 2001 From: Emmanuel Turquin Date: Wed, 3 Nov 2021 19:49:12 +0100 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 ef67484ccb4..fc73bc1b665 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added new functions that sample the custom buffer in custom passes (CustomPassSampleCustomColor and CustomPassLoadCustomColor) to handle the RTHandleScale automatically. - Added new panels to Rendering Debugger Display Stats panel, displaying improved CPU/GPU frame timings and bottlenecks. - Added API to edit diffusion profiles and set IES on lights. +- Added public API to reset path tracing accumulation, and check its status. ### Fixed - Fixed decal position when created from context menu. (case 1368987)