Skip to content

Conversation

skhiat
Copy link
Contributor

@skhiat skhiat commented Sep 17, 2020

SSR Improvement

The improvement:

  • Uses the VNDF Importance Sampling
  • Temporal accumulation controllable with the new parameter 'Accumulation Amount' (0 No accumulation, 1 Accumulation uses multiple frames). More accumulation generate more ghosting
    image

Better match:
New SSR:
image

Pathtracer (Bounce == 2):
image

Checklist for PR maker

Docs team contacts sheet.

  • Have you added a graphic test for your PR (if needed)? When you add a new feature, or discover a bug that tests don't cover, please add a graphic test.

Purpose of this PR

SSR will give us a better match with Pathtracer.

  • Blurriness (blur radius)
  • With the adjustment of "Accumulation Amount" will be "override" by the code depending of the motion vector (of the original point and the hit point).

Testing status

On the scene add a moving object for example a cylinder and move it, note the motion vector for objects are only available in the GameView:
` public float speed = 5.0f;

// Update is called once per frame
void Update()
{
    transform.Rotate(Vector3.right * speed * Time.deltaTime);
}`

For rough surface, we will have more noise even with large accumulation, on region of this cylinder.
Ref:
https://drive.google.com/file/d/1zyrvVWU-bzVqYOyOERe7OMvnZXtjbxzI/view?usp=sharing

Parameters to consider during a test:
Object thickness, which allow the ray to pass behind thin object:
image
Correct value: scene dependents

Allow more accumulation with multiple frame:
image

Yamato: (Select your branch):
https://yamato.prd.cds.internal.unity3d.com/jobs/902-Graphics


Comments to reviewers

Notes for the reviewers you have assigned.

skhiat added 14 commits July 17, 2020 08:39
… into HDRP/ssr_improvement

# Conflicts:
#	com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
… into HDRP/ssr_improvement

# Conflicts:
#	com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs
… into HDRP/ssr_improvement

# Conflicts:
#	com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceReflections.compute
… into HDRP/ssr_improvement

# Conflicts:
#	com.unity.render-pipelines.high-definition/CHANGELOG.md
#	com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs.hlsl
@anisunity anisunity self-requested a review September 25, 2020 12:18
// Pick which subpixel we will be launching our effects from
float subPixelSample = GetBNDSequenceSample(positionSS, globalSampleIndex, 3);
int subPixel = clamp((int)(subPixelSample * 4.0), 0, 3);
uint2 shift = HalfResIndexToCoordinateShift[subPixel];
Copy link
Contributor

@anisunity anisunity Sep 25, 2020

Choose a reason for hiding this comment

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

This is code picked from RayTracingReflection.compute is meant to handle BSDF data info fetch in half res mode, in the current state SSR doesn't have half res mode. This is a copy paste mistake i guess.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We switched to an algorithm that does temporal accumulation this shift help for quality. I am open to discuss that.

Copy link
Contributor

Choose a reason for hiding this comment

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

This usage of the code, if on purpose, increases the variance and biases the signal even more, I am sure of that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That help on the edges & very close hit (corners: Wall vs Floor/Ceilling)

@skhiat skhiat marked this pull request as ready for review October 23, 2020 13:20
…HDRP/ssr_improvement

# Conflicts:
#	com.unity.render-pipelines.high-definition/CHANGELOG.md
@@ -1,3 +1,6 @@
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs.hlsl"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need those hearders here? it is not expected that we put such header in VertMesh.hlsl

if (hdCamera.isFirstFrame || hdCamera.cameraFrameCount <= 2)
cb._SsrAccumulationAmount = 1.0f;
else
cb._SsrAccumulationAmount = Mathf.Pow(2, Mathf.Lerp(-0.0f, -7.0f, volumeSettings.accumulationFactor.value));
Copy link
Contributor

Choose a reason for hiding this comment

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

typo, there is a -0.0 here

passData.ssrAccum = builder.WriteTexture(ssrAccum);
passData.ssrAccumPrev = builder.WriteTexture(ssrAccumPrev);
passData.lightingTexture = builder.CreateTransientTexture(new TextureDesc(Vector2.one, true, true)
{ colorFormat = GraphicsFormat.R16G16B16A16_SFloat, clearBuffer = true, clearColor = Color.clear, enableRandomWrite = true, name = "SSR_Lighting_Texture" });
Copy link
Contributor

Choose a reason for hiding this comment

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

this must be of color buffer format (i.e 101010f or 16f depends on the option of hdrp asset)

Copy link
Contributor

Choose a reason for hiding this comment

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

I see it is not related to your PR, I will take care of it separately


if (!usePBRAlgo)
{
CoreUtils.SetKeyword(cmd, "SSR_APPROX", false);
Copy link
Contributor

@sebastienlagarde sebastienlagarde Oct 25, 2020

Choose a reason for hiding this comment

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

I don't understand why you do this at the end. You must no do this but instead do:

CoreUtils.SetKeyword(cmd, "SSR_APPROX", !usePBRAlgo); at the beginning.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh unless it is for the transparent case?

cmd.DispatchCompute(cs, parameters.reprojectionKernel, HDUtils.DivRoundUp(parameters.width, 8), HDUtils.DivRoundUp(parameters.height, 8), parameters.viewCount);

if (parameters.transparentSSR)
CoreUtils.SetKeyword(cmd, "DEPTH_SOURCE_NOT_FROM_MIP_CHAIN", false);
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need to reset keyword at the end (unless you reuse the shader, you should setup

CoreUtils.SetKeyword(cmd, "DEPTH_SOURCE_NOT_FROM_MIP_CHAIN", parameters.transparentSSR); at the beginning

Copy link
Contributor

Choose a reason for hiding this comment

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

oh unless it is for the transparent case?

@sebastienlagarde sebastienlagarde merged commit 80042e3 into master Oct 25, 2020
@sebastienlagarde sebastienlagarde deleted the HDRP/ssr_improvement branch October 25, 2020 23:24
sebastienlagarde added a commit that referenced this pull request Oct 25, 2020
* Change reflection direction to match GGX

* local tmp

* Temp Denoise and Inpainting

* Backup remote work

* Remove blur step

* Add doc

* ChangeLog + small fix

* Speed dependend convergence

* Clean code

* Fix multicamera + SSR

* Cleanup

* Saturate local & target velocity

* Fix RenderGraph

* Code cleaning + comments

* Fix feedback

* Support previous & new algorithm

* missing file: support both algorithm

* fix for default RenderGraph

* Simplify UI

* Remap parameters for more userfriendly parametrization

* fix doc missing

* Clean up

* New rendergraph fix

* temp

* Fix alloc issues RenderGraphs

* Update default values

* Add NaN killer

* New strategy for 'first frame' reset

* Update doc with clearer explaination

* Perf improvement

* Move code

* Fix GCAlloc issues

* Fix SSR & Transparent, both pipe RenderGraph & non-RenderGraph

* Add what's new

* Regenerate shader includes

* Fix API Test

* Fix name RayTracingCommon.hlsl

* Typo simplification

* Update VertMesh.hlsl

* Update VertMesh.hlsl

* Fix parity RG & Non-RG

Co-authored-by: Sebastien Lagarde <sebastien@unity3d.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants