Skip to content

[HDRP][Path Tracing] Sky settings now properly taken into account when using recorder #4856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed cropping issue with the compositor camera bridge (case 1340549).
- Fixed the transparent cutoff not working properly in semi-transparent and color shadows (case 1340234).
- Fixed object outline flickering with TAA.
- Fixed issue with sky settings being ignored when using the recorder and path tracing (case 1340507).

### Changed
- Changed Window/Render Pipeline/HD Render Pipeline Wizard to Window/Rendering/HDRP Wizard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,8 @@ private void OnSceneGui(SceneView sv)

#endif // UNITY_EDITOR

private void CheckDirtiness(HDCamera hdCamera)
private void CheckDirtiness(HDCamera hdCamera, int camID, CameraData camData)
{
if (m_SubFrameManager.isRecording)
{
return;
}

// Grab the cached data for the current camera
int camID = hdCamera.camera.GetInstanceID();
CameraData camData = m_SubFrameManager.GetCameraData(camID);

// Check camera resolution dirtiness
if (hdCamera.actualWidth != camData.width || hdCamera.actualHeight != camData.height)
{
Expand Down Expand Up @@ -367,21 +358,29 @@ TextureHandle RenderPathTracing(RenderGraph renderGraph, HDCamera hdCamera, Text
if (!pathTracingShader || !m_PathTracingSettings.enable.value)
return TextureHandle.nullHandle;

CheckDirtiness(hdCamera);
int camID = hdCamera.camera.GetInstanceID();
CameraData camData = m_SubFrameManager.GetCameraData(camID);

if (!m_SubFrameManager.isRecording)
{
CheckDirtiness(hdCamera, camID, camData);

// If we are recording, the max iteration is set/overridden by the subframe manager, otherwise we read it from the path tracing volume
m_SubFrameManager.subFrameCount = (uint)m_PathTracingSettings.maximumSamples.value;
}
else
{
// When recording, as be bypass dirtiness checks which update camData, we need to indicate whether we want to render a sky or not
camData.skyEnabled = (hdCamera.clearColorMode == HDAdditionalCameraData.ClearColorMode.Sky);
m_SubFrameManager.SetCameraData(camID, camData);
}

#if UNITY_HDRP_DXR_TESTS_DEFINE
if (Application.isPlaying)
m_SubFrameManager.subFrameCount = 1;
#endif

var cameraData = m_SubFrameManager.GetCameraData(hdCamera.camera.GetInstanceID());
if (cameraData.currentIteration < m_SubFrameManager.subFrameCount)
if (camData.currentIteration < m_SubFrameManager.subFrameCount)
{
// Keep a sky texture around, that we compute only once per accumulation (except when recording, with potential camera motion blur)
if (m_RenderSky || m_SubFrameManager.isRecording)
Expand All @@ -390,7 +389,7 @@ TextureHandle RenderPathTracing(RenderGraph renderGraph, HDCamera hdCamera, Text
m_RenderSky = false;
}

RenderPathTracing(m_RenderGraph, hdCamera, cameraData, m_FrameTexture, m_SkyTexture);
RenderPathTracing(m_RenderGraph, hdCamera, camData, m_FrameTexture, m_SkyTexture);
}

RenderAccumulation(m_RenderGraph, hdCamera, m_FrameTexture, colorBuffer, true);
Expand Down