NVIDIAGameWorks/RayTracingDenoiser

Question on Hit Distance Reconstruction: Why use border of 1 instead of 2?

thesmallcreeper opened this issue · 5 comments

Hi,

With the new release I was very interested in how you attacked hit distance reconstruction problem.
As I understand at sample code a Bayer sequence 4x4 is used with a neighbor search at denoiser (reLAX for example) in order to find a good estimation of specular hit distance in case the sample shot a "diffuse-ray".
Because the search is being done with border of 1 this mean at least 1 in 4 (0.25) samples should be specular sampled.
However if border of 2 is used this threshold can come down to 1 in 16 samples (0.0625).
Some test code: https://godbolt.org/z/YGYo1rjnM

What the reasoning behind choosing border of 1 instead of 2? I am curious, want to learn 😄
Maybe allow an option? Also providing more info at readme can be useful for others.

Thank you in advance.

What the reasoning behind choosing border of 1 instead of 2?

Performance. Additionally - the initial proposal was to clamp stochastic probabilities to [0.25; 0.75] (if not pure "0" or "1") and use 3x3 reconstruction filter, naively assuming that among 9 pixels there should be "at least one good". It's was a wrong assumption because random numbers work in a different (random) way for short sequences (9 out of INF in our case). I just came up with the idea to use Bayer dithering to guarantee a "good sample".

5x5 search as an option in addition to 3x3?

Easily doable.

What about signal reconstruction in the same pass? Will it work better than dividing radiance by the probability of the initial diff / spec split?

I think it may help. It should help to reduce overall signal entropy (which is obviously bumped up in case of probabilistic sampling).

Also providing more info at readme can be useful for others.

Currently the doc has this:

Noise in provided hit distances must follow diffuse or specular lobe. It implies the following:
 - hitT for roughness = 0 must be clean
 - In case of probabilistic selection of diffuse / specular sampling at the primary hit, provided hitT must follow the following rules:
     -- should not be divided by pdf
     -- if diffuse or specular sampling is skipped hitT must be set to 0 for corresponding signal type
     -- better enable enableHitDistanceReconstruction in a denoiser settings (if supported)

and (in another section):

[NRD] In case of probabilistic diffuse / specular split at the primary hit, it's recommended to enable hit distance reconstruction pass (enableHitDistanceReconstruction if exposed in the selected denoiser).

what would you recommend to add?

Most useful part - give me a few days to experiment with:

  • 5x5 reconstruction as an option
  • radiance reconstruction (will follow 3x3 / 5x5 setting) as an option too

Thank you for your response.

Bayer dithering idea was a good one.
About readme I recommend adding the constraints that should be followed for a successful hit distance reconstruction. For reLAX for example something like "For successful hit distance reconstruction at least one specular sample should exist on every 3x3 region. Bayer dithering can be used to achieve that, look "IndirectRays.cs.hsls" shader of NRDsample."

Since you may add a relevant feature I keep the issue open. Feel free to close it whenever you want.

Yes, sounds good to me. Thanks, it will be added soon.

@thesmallcreeper 3x3 and 5x5 hitT reconstruction modes have been implemented! Corresponding settings exposed in the UI. Tracer clamps probabilities to:

  • 3x3 - 1/4
  • 5x5 - 1/16

README has been updated too to better explain how to use NRD with probabilistic sampling.
Thanks for the suggestion!

@dzhdanNV Thank you too. Also learned something along the way. 😄