Skip to content

Commit 6da816c

Browse files
authored
[HDRP][Path Tracing] Exposed 3 methods related to path tracing and accumulation. (#6197)
* Made a few methods related to path tracing and accumulation public. * Updated changelog.
1 parent e375136 commit 6da816c

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

com.unity.render-pipelines.high-definition/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1212
- Added new functions that sample the custom buffer in custom passes (CustomPassSampleCustomColor and CustomPassLoadCustomColor) to handle the RTHandleScale automatically.
1313
- Added new panels to Rendering Debugger Display Stats panel, displaying improved CPU/GPU frame timings and bottlenecks.
1414
- Added API to edit diffusion profiles and set IES on lights.
15+
- Added public API to reset path tracing accumulation, and check its status.
1516

1617
### Fixed
1718
- Fixed decal position when created from context menu. (case 1368987)

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Accumulation/SubFrameManager.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ internal void PrepareNewSubFrame()
153153
foreach (int camID in m_CameraCache.Keys.ToList())
154154
maxIteration = Math.Max(maxIteration, GetCameraData(camID).currentIteration);
155155

156-
if (maxIteration == m_AccumulationSamples)
156+
if (maxIteration >= m_AccumulationSamples)
157157
{
158158
Reset();
159159
}
@@ -264,6 +264,18 @@ public void PrepareNewSubFrame()
264264
m_SubFrameManager.PrepareNewSubFrame();
265265
}
266266

267+
/// <summary>
268+
/// Checks if the multi-frame accumulation is completed for a given camera.
269+
/// </summary>
270+
/// <param name="hdCamera">Camera for which the accumulation status is checked.</param>
271+
/// <returns><c>true</c> if the accumulation is completed, <c>false</c> otherwise.</returns>
272+
public bool IsFrameCompleted(HDCamera hdCamera)
273+
{
274+
int camID = hdCamera.camera.GetInstanceID();
275+
CameraData camData = m_SubFrameManager.GetCameraData(camID);
276+
return camData.currentIteration >= m_SubFrameManager.subFrameCount;
277+
}
278+
267279
class RenderAccumulationPassData
268280
{
269281
public ComputeShader accumulationCS;

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,26 @@ void ReleasePathTracing()
112112
#endif // UNITY_EDITOR
113113
}
114114

115-
internal void ResetPathTracing()
115+
/// <summary>
116+
/// Resets path tracing accumulation for all cameras.
117+
/// </summary>
118+
public void ResetPathTracing()
116119
{
117120
m_RenderSky = true;
118121
m_SubFrameManager.Reset();
119122
}
120123

124+
/// <summary>
125+
/// Resets path tracing accumulation for a specific camera.
126+
/// </summary>
127+
/// <param name="hdCamera">Camera for which the accumulation is reset.</param>
128+
public void ResetPathTracing(HDCamera hdCamera)
129+
{
130+
int camID = hdCamera.camera.GetInstanceID();
131+
CameraData camData = m_SubFrameManager.GetCameraData(camID);
132+
ResetPathTracing(camID, camData);
133+
}
134+
121135
internal CameraData ResetPathTracing(int camID, CameraData camData)
122136
{
123137
m_RenderSky = true;

0 commit comments

Comments
 (0)