Skip to content
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

[HDRP][Path Tracing] Replaced recursive continuation rays with loop in ray generation #7090

Closed
wants to merge 50 commits into from

Conversation

eturquin
Copy link
Contributor

@eturquin eturquin commented Feb 10, 2022

Although user-wise there should not be too much visible change (if at all), other than slightly improved performance (in the 5-10% range after early tests), this PR removes the recursion from the path tracing, with no more continuation rays shot from closesthit().

This allow us to use an arbitrary number of bounces (still caped to 10 in the UI, but could be increased to any value now), without adding to the recursion level. This also makes aspects of the code cleaner and easier to read (no more do we have to deal with different miss() functions, for instance).

This will also hopefully open the door to other optimizations, like returning a BSDFData-like payload from closesthit() and do all shading computations in the raygen(), or even return a materialID and compute BSDFData or equivalent in the raygen() too.

TO BE TESTED: general path tracing usage, making sure nothing is blatantly broken. 5 of the tests have changed slightly, because of a Russian roulette adjustment. Refs have been updated. Also, the old intensity clamping scheme cannot be applied anymore, without "faking" recursion, so a slightly different one is now in place, that may produce a bit more fireflies.

@remi-chapelain remi-chapelain requested a review from a team February 11, 2022 09:32
@eturquin
Copy link
Contributor Author

Yamato currently fails with DXR tests for unrelated matters. I tried running all HDRP tests locally, and they are all green.

Copy link
Contributor

@pmavridis pmavridis left a comment

Choose a reason for hiding this comment

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

Looks good to me, removing recursion is definitely the right direction for the path tracer.

@remi-chapelain
Copy link
Contributor

Preliminary tests shows at least three things:

  • There is somewhat more "fog" compared to master
  • The process of accumulation is substantially slower (which is expected but not that much) by roughly 167% in an inside environment and 135% outside (where there's more ray miss basically)
  • The noise pattern is different (which is expected)

330a8dadba1bf3fd96178c3bcc646705

c4e58fd3450b41843275d913575ffef1

Will wait for @eturquin to come back to re-evaluate what can be done for speed and fog.

Copy link
Contributor

@sebastienlagarde sebastienlagarde left a comment

Choose a reason for hiding this comment

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

@eturquin see with QA for validation, then try to merge before cutoff (with yamato validation)

@sebastienlagarde
Copy link
Contributor

hmm.. need to merge master first

Copy link
Contributor

@remi-chapelain remi-chapelain left a comment

Choose a reason for hiding this comment

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

For fog issue. (WIP)

Copy link
Contributor

@remi-chapelain remi-chapelain left a comment

Choose a reason for hiding this comment

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

Fog issue has been fixed, now approving ✔️
The accumulated images matches between this PR and master. ✔️

This will allow to raise the max depth by default and allow more than 10 for really complex scene (with lots of mirrors or glass etc)

There's is two or three slight differences that can be noted for future reference:

  • Perf can a bit a little bit better or a little bit worse (depending on the scene and the setup)
  • Intensity clamping is a bit different so there's going to be more fireflies by default (the difference is very light and can be seen only when zooming a lot)
  • Noise can be a bit different
f5967f2c2a74150e369a3cc5b6e85e4d.mp4

@eturquin
Copy link
Contributor Author

In case there still is a tiny window to merge this, it is ready.

@sebastienlagarde
Copy link
Contributor

replicated on provate github PR

unity-emilk pushed a commit that referenced this pull request May 24, 2022
…n ray generation (v3)

Although user-wise there should not be too much visible change (if at all), other than slightly improved performance (in the 5-10% range after early tests), this PR removes the recursion from the path tracing, with no more continuation rays shot from closesthit().

This allow us to use an arbitrary number of bounces (still caped to 32 in the UI, but could be increased to any value now), without adding to the recursion level. This also makes aspects of the code cleaner and easier to read (no more do we have to deal with different miss() functions, for instance).

This will also hopefully open the door to other optimizations, like returning a BSDFData-like payload from closesthit() and do all shading computations in the raygen(), or even return a materialID and compute BSDFData or equivalent in the raygen() too.

Note that this PR existed on the public repository already, and was validated by all reviewers, but slightly too late to be merged before the repo change: #7090
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.

4 participants