-
Notifications
You must be signed in to change notification settings - Fork 839
[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
Conversation
output = builder.UseColorBuffer(renderGraph.CreateTexture( | ||
new TextureDesc(Vector2.one, true, true) | ||
{ | ||
colorFormat = GraphicsFormat.R8G8B8A8_UNorm, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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);
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this 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
088fcde
to
f0c59d2
Compare
f38c2dc
to
2d7d0f9
Compare
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. HDRP 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. |
4ef9bcc
to
5b8b629
Compare
be sure you run Yamato |
631a6bb
to
2e1ad95
Compare
There was a problem hiding this 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
2e1ad95
to
cebaed6
Compare
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:
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.