Skip to content

[HDRP] Fix render object after taa jittering #5088

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
Jul 13, 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 @@ -299,6 +299,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed VFX flag "Exclude From TAA" not working for some particle types.
- 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).
- Fixed objects disappearing from Lookdev window when entering playmode (case 1309368).
- Fixed rendering of objects just after the TAA pass (before post process injection point).

### 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 @@ -483,6 +483,7 @@ TextureHandle RenderPostProcess(RenderGraph renderGraph,
if (hdCamera.antialiasing == HDAdditionalCameraData.AntialiasingMode.TemporalAntialiasing)
{
source = DoTemporalAntialiasing(renderGraph, hdCamera, depthBuffer, motionVectors, depthBufferMipChain, source, postDoF: false, "TAA Destination");
RestoreNonjitteredMatrices(renderGraph, hdCamera);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, however if physically based dof is enabled we have an additional TAA pass which I wonder if it means we should move the "Post TAA" injection point

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The post TAA point is called before post-process, so I don't think it's a good idea to put it after dof. In any case, I think it will break a lot of stuff if we do that.

About the additional TAA pass, is it done on the whole screen or another buffer?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The post TAA point is called before post-process, so I don't think it's a good idea to put it after dof. In any case, I think it will break a lot of stuff if we do that.

Before post process but after TAA I assume, no? What I mean is that by doing so DoF runs on the full final color buffer after, so it will smudge what the user didn't want to smudge.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess can be a matter of documentation, but is something we should address somehow

}
else if (hdCamera.antialiasing == HDAdditionalCameraData.AntialiasingMode.SubpixelMorphologicalAntiAliasing)
{
Expand Down Expand Up @@ -538,6 +539,34 @@ TextureHandle RenderPostProcess(RenderGraph renderGraph,
return dest;
}

class RestoreNonJitteredPassData
{
public ShaderVariablesGlobal globalCB;
public HDCamera hdCamera;
}

void RestoreNonjitteredMatrices(RenderGraph renderGraph, HDCamera hdCamera)
{
using (var builder = renderGraph.AddRenderPass<RestoreNonJitteredPassData>("Restore Non-Jittered Camera Matrices", out var passData))
{
passData.hdCamera = hdCamera;
passData.globalCB = m_ShaderVariablesGlobalCB;

builder.SetRenderFunc((RestoreNonJitteredPassData data, RenderGraphContext ctx) =>
{
// Note about AfterPostProcess and TAA:
// When TAA is enabled rendering is jittered and then resolved during the post processing pass.
// It means that any rendering done after post processing need to disable jittering. This is what we do with hdCamera.UpdateViewConstants(false);
// The issue is that the only available depth buffer is jittered so pixels would wobble around depth tested edges.
// 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.
hdCamera.UpdateAllViewConstants(false);
hdCamera.UpdateShaderVariablesGlobalCB(ref m_ShaderVariablesGlobalCB);

ConstantBuffer.PushGlobal(ctx.cmd, m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal);
});
}
}

#region AfterPostProcess
class AfterPostProcessPassData
{
Expand Down Expand Up @@ -576,14 +605,6 @@ TextureHandle RenderAfterPostProcessObjects(RenderGraph renderGraph, HDCamera hd
builder.SetRenderFunc(
(AfterPostProcessPassData data, RenderGraphContext ctx) =>
{
// Note about AfterPostProcess and TAA:
// When TAA is enabled rendering is jittered and then resolved during the post processing pass.
// It means that any rendering done after post processing need to disable jittering. This is what we do with hdCamera.UpdateViewConstants(false);
// The issue is that the only available depth buffer is jittered so pixels would wobble around depth tested edges.
// 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.
data.hdCamera.UpdateAllViewConstants(false);
data.hdCamera.UpdateShaderVariablesGlobalCB(ref data.globalCB);

UpdateOffscreenRenderingConstants(ref data.globalCB, true, 1.0f);
ConstantBuffer.PushGlobal(ctx.cmd, data.globalCB, HDShaderIDs._ShaderVariablesGlobal);

Expand Down