Skip to content

Commit ae9e7a6

Browse files
Antoine Lelievresebastienlagarde
andauthored
[HDRP] Fix render object after taa jittering (#5088)
* Add a pass after TAA to restore non jittered matrices * updated changelog Co-authored-by: sebastienlagarde <[email protected]>
1 parent ce1f22a commit ae9e7a6

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
299299
- Fixed VFX flag "Exclude From TAA" not working for some particle types.
300300
- Fixed Dof and MSAA. DoF is now using the min depth of the per-pixel MSAA samples when MSAA is enabled. This removes 1-pixel ringing from in focus objects (case 1347291).
301301
- Fixed objects disappearing from Lookdev window when entering playmode (case 1309368).
302+
- Fixed rendering of objects just after the TAA pass (before post process injection point).
302303

303304
### Changed
304305
- Changed Window/Render Pipeline/HD Render Pipeline Wizard to Window/Rendering/HDRP Wizard

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

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ TextureHandle RenderPostProcess(RenderGraph renderGraph,
483483
if (hdCamera.antialiasing == HDAdditionalCameraData.AntialiasingMode.TemporalAntialiasing)
484484
{
485485
source = DoTemporalAntialiasing(renderGraph, hdCamera, depthBuffer, motionVectors, depthBufferMipChain, source, postDoF: false, "TAA Destination");
486+
RestoreNonjitteredMatrices(renderGraph, hdCamera);
486487
}
487488
else if (hdCamera.antialiasing == HDAdditionalCameraData.AntialiasingMode.SubpixelMorphologicalAntiAliasing)
488489
{
@@ -538,6 +539,34 @@ TextureHandle RenderPostProcess(RenderGraph renderGraph,
538539
return dest;
539540
}
540541

542+
class RestoreNonJitteredPassData
543+
{
544+
public ShaderVariablesGlobal globalCB;
545+
public HDCamera hdCamera;
546+
}
547+
548+
void RestoreNonjitteredMatrices(RenderGraph renderGraph, HDCamera hdCamera)
549+
{
550+
using (var builder = renderGraph.AddRenderPass<RestoreNonJitteredPassData>("Restore Non-Jittered Camera Matrices", out var passData))
551+
{
552+
passData.hdCamera = hdCamera;
553+
passData.globalCB = m_ShaderVariablesGlobalCB;
554+
555+
builder.SetRenderFunc((RestoreNonJitteredPassData data, RenderGraphContext ctx) =>
556+
{
557+
// Note about AfterPostProcess and TAA:
558+
// When TAA is enabled rendering is jittered and then resolved during the post processing pass.
559+
// It means that any rendering done after post processing need to disable jittering. This is what we do with hdCamera.UpdateViewConstants(false);
560+
// The issue is that the only available depth buffer is jittered so pixels would wobble around depth tested edges.
561+
// In order to avoid that we decide that objects rendered after Post processes while TAA is active will not benefit from the depth buffer so we disable it.
562+
hdCamera.UpdateAllViewConstants(false);
563+
hdCamera.UpdateShaderVariablesGlobalCB(ref m_ShaderVariablesGlobalCB);
564+
565+
ConstantBuffer.PushGlobal(ctx.cmd, m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal);
566+
});
567+
}
568+
}
569+
541570
#region AfterPostProcess
542571
class AfterPostProcessPassData
543572
{
@@ -576,14 +605,6 @@ TextureHandle RenderAfterPostProcessObjects(RenderGraph renderGraph, HDCamera hd
576605
builder.SetRenderFunc(
577606
(AfterPostProcessPassData data, RenderGraphContext ctx) =>
578607
{
579-
// Note about AfterPostProcess and TAA:
580-
// When TAA is enabled rendering is jittered and then resolved during the post processing pass.
581-
// It means that any rendering done after post processing need to disable jittering. This is what we do with hdCamera.UpdateViewConstants(false);
582-
// The issue is that the only available depth buffer is jittered so pixels would wobble around depth tested edges.
583-
// In order to avoid that we decide that objects rendered after Post processes while TAA is active will not benefit from the depth buffer so we disable it.
584-
data.hdCamera.UpdateAllViewConstants(false);
585-
data.hdCamera.UpdateShaderVariablesGlobalCB(ref data.globalCB);
586-
587608
UpdateOffscreenRenderingConstants(ref data.globalCB, true, 1.0f);
588609
ConstantBuffer.PushGlobal(ctx.cmd, data.globalCB, HDShaderIDs._ShaderVariablesGlobal);
589610

0 commit comments

Comments
 (0)