Skip to content

[Fogbugz # 1345143] DLSS: Aleviating some of the ghosting artifacts for partciles by using the color bias mask #5081

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 1 commit into from
Jul 28, 2021

Conversation

kecho
Copy link
Contributor

@kecho kecho commented Jul 6, 2021

Purpose of this PR

Fogbugz: https://fogbugz.unity3d.com/f/cases/1345143/

DLSS has heavy ghost artifacts on pixels that lack velocity. This change uses the color bias mask feature of DLSS to aleviate some of the heavy ghosting.

This PR creates a new pass in graphics that reads stencil, and blits a mask of 1,1,1,1 if the stencil passes. The stencil ref used is transparent passes "Exclude from TAA". This results in a mask for particles that DLSS can use.


Testing status

Tested locally by using the HDRP template on windows dx11, dropping some butterflies and falling leaves VFX, making them transparent, and clicking on the "Exclude from TAA" checkbox.

Further testing:

  • Must test on dx12 & vulkan
  • Should test on hardware/software

Dont expect ghosting to be completely gone, there is still ghosting remaining. This change should alleviate some of the ghosting.


Comments to reviewers

I discovered that VFXStencilForward macro isnt used, thus the "Exclude from TAA" option never worked. I have another PR #5080 that fixes this problem (is an isolated cherry pick). 5080 must go in first.

output = builder.UseColorBuffer(renderGraph.CreateTexture(
new TextureDesc(Vector2.one, true, true)
{
colorFormat = GraphicsFormat.R8G8B8A8_UNorm,
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume the format is required by DLSS? Sounds a bit of a shame to use 32 bit for a binary mask

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The documentation says that DLSS can take an R8_Unorm, however DLSS crashes hard (on the CPU) when we pass anything that doesnt have an RGBA swizzle.
Im prepping something to ask nvidia why is this the case. For now this will have to do.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ouch, yeah whatever works for now

Copy link
Contributor

Choose a reason for hiding this comment

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

you should add a comment in the code about it

(DLSSColorMaskPassData data, RenderGraphContext ctx) =>
{
Rect targetViewport = new Rect(0.0f, 0.0f, data.destWidth, data.destHeight);
ctx.cmd.SetViewport(targetViewport);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should be setting the stencil bits from here too instead of relying on the fact that the hardcoded one will remain the same, i.e.

data.colorMaskMaterial.SetInt(HDShaderIDs._StencilMask, (int)StencilUsage.ExcludeFromTAA); data.colorMaskMaterial.SetInt(HDShaderIDs._StencilRef, (int)StencilUsage.ExcludeFromTAA);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Builtin/BuiltinData.hlsl"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this and the following 2 includes? (My guess is not? In that case we can remove and make this compile a bit faster)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@FrancescoC-unity FrancescoC-unity left a comment

Choose a reason for hiding this comment

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

Small comments, but generally lgtm

@kecho kecho force-pushed the HDRP/dlss-taa-particle-ghost-fix branch 2 times, most recently from 088fcde to f0c59d2 Compare July 8, 2021 12:00
@kecho kecho changed the base branch from hd/bugfix to master July 8, 2021 12:01
@kecho kecho requested a review from a team July 9, 2021 13:27
@kecho kecho force-pushed the HDRP/dlss-taa-particle-ghost-fix branch from f38c2dc to 2d7d0f9 Compare July 9, 2021 15:03
@github-actions
Copy link

github-actions bot commented Jul 9, 2021

Hi! This comment will help you figure out which jobs to run before merging your PR. The suggestions are dynamic based on what files you have changed.
Link to Yamato: https://yamato.cds.internal.unity3d.com/jobs/902-Graphics
Search for your PR branch using the sidebar on the left, then add the following segment(s) to the end of the URL (you may need multiple tabs depending on how many packages you change)

HDRP
/.yamato%252Fall-hdrp.yml%2523PR_HDRP_2021.2

Depending on the scope of your PR, you may need to run more jobs than what has been suggested. Please speak to your lead or a Graphics SDET (#devs-graphics-automation) if you are unsure.

@kecho kecho force-pushed the HDRP/dlss-taa-particle-ghost-fix branch from 4ef9bcc to 5b8b629 Compare July 9, 2021 17:02
@sebastienlagarde sebastienlagarde marked this pull request as ready for review July 12, 2021 17:18
@sebastienlagarde
Copy link
Contributor

be sure you run Yamato

@kecho kecho force-pushed the HDRP/dlss-taa-particle-ghost-fix branch 2 times, most recently from 631a6bb to 2e1ad95 Compare July 13, 2021 17:02
Copy link
Contributor

@iM0ve iM0ve left a comment

Choose a reason for hiding this comment

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

This was difficult for me to reproduce and the effect/improvement is very subtle and likely setup dependant. I noticed a small improvement as mentioned in the description

Whats tested:

  • Modified the template to get the visible artifact
  • Compared the issue before vs after the PR
  • For regression testing in editor mode switched to DX11, DX12 and Vulkan
  • Tried both Software and Hardware modes

No issues found

Demo

Before

Before.mp4

After

After.mp4

Adding stencil values manually

Removing redundant includes

Changelog

DLSS runtime asset.

Compilation fix
@kecho kecho force-pushed the HDRP/dlss-taa-particle-ghost-fix branch from 2e1ad95 to cebaed6 Compare July 28, 2021 15:16
@sebastienlagarde sebastienlagarde merged commit 63fd982 into master Jul 28, 2021
@sebastienlagarde sebastienlagarde deleted the HDRP/dlss-taa-particle-ghost-fix branch July 28, 2021 15:22
@kecho kecho restored the HDRP/dlss-taa-particle-ghost-fix branch July 28, 2021 15:27
@kecho kecho deleted the HDRP/dlss-taa-particle-ghost-fix branch July 28, 2021 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants