Skip to content

Conversation

johnpars
Copy link
Contributor

@johnpars johnpars commented Sep 29, 2021

Purpose of this PR

This PR includes various fixes for our physically based hair shading, namely:

  • Pathtraced hair reference is now validated against a ground truth (PBRT).
  • Pathtraced hair reference is now importance sampled.
  • Pathtraced hair reference now correctly supports both near and far field models (by default using near).
  • Adds a furnace test to test for energy conservation of the hair reference.
  • Adds two new helpful color parameterization modes (Explicit absorption and melanin concentration)
  • Fixes various subtle issues in our dual scattering.

image

This work began with the intent to fix some discrepancies I observed between our dual scattering approximation and our pathtraced reference. However I realized that even our reference itself had some issues, which made it an unreliable multiple scattering reference. As such, I began a process of validating our reference, so that we may ultimately validate our multiple scattering approximation. This PR is a culmination of everything that was necessary to achieve that goal.

Ground Truth

The pathtraced reference was fixed with the help of this PBRT supplemental listing which shared helpful implementation details on the same model we use. Following that paper, we now are in good agreement with PBRT:

image

Importance Sampling

Importance sampling was also added, drastically reducing the variance we otherwise experience from uniform sampling.

64 SPP, BM = 0.8, BN = 0.7
image

Near/Far

Fixed an issue where the offset fiber term from tube intersection was being incorrectly calculated, causing incorrect results of the near field model. The D'Eon far field model was also removed and we "fake" a far field by choosing a random offset for every sample (instead of integrating over the fiber width).

image

Furnace Test

I added a furnace test to confirm that the reference is now energy conserving. The test is performed by setting up a theoretical fiber with zero absorption and confirming that the outgoing energy is close to 1 for uniform incident lighting. This is done for varying intervals of roughness. I added this test via our test runner framework but I leave it disabled for now (only enabled it locally for testing).

image

Color Modes

I added some other helpful color parameterization modes. Specifically: Absorption and Melanin Concentration. The absorption mode was added so that we can directly submit absorption coefficients to the model to reference our results against other papers. The melanin mode was added as an alternative but intuitive way to define the absorption in terms of pigmentation. I will keep these modes hidden in the UI from now, but can easily be enabled after some further discussion with artists (it will default to the normal color mode).

Color Modes

Dual Scattering Fixes

Ultimately the above work made it easier to iterate on our multiple scattering approximation and easily determine if there were issues. Numerous issues were discovered and corrected. Overall the approximation should be much closer in agreement with the reference.

Replacement

There are however still some unresolved problems:

  • Apparent energy loss at low roughness values, compared to the reference. It is almost necesarry to tune the strand count to something lower to counter act it.
  • Slightly different highlight width compared to reference, this may simply be due to the gaussian we use to approximate the longitudinal scattering.

Testing status

~


Comments to reviewers

~

@github-actions
Copy link

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_trunk
With changes to HDRP packages, you should also run
/.yamato%252Fall-lightmapper.yml%2523PR_LightMapper_trunk

SRP Core
You could run ABV on your branch before merging your PR, but it will start A LOT of jobs. Please be responsible about it and run it only when you feel the PR is ready:
/.yamato%252F_abv.yml%2523all_project_ci_trunk
Be aware that any modifications to the Core package impacts everyone in the Graphics repo so please discuss the PR with your lead.

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.

@johnpars johnpars changed the title Hdrp/hair bsdf validation Fixes for Hair Reference and Multiple Scattering Approximation Sep 29, 2021
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.

@johnpars could you also update the documentation. In your various PR description there is a lot of informatoin which should be also in documentation. Could you add a new pages in doc about the path tracing hair and how to test the white furnace for example.

i.e overall we need users to be able to understand what the model provide :) can be done in a separate PR, thanks

@sebastienlagarde sebastienlagarde marked this pull request as ready for review September 30, 2021 07:29
@sebastienlagarde
Copy link
Contributor

For QA: the testing is covered by demo team.

@sebastienlagarde sebastienlagarde merged commit e718a8e into master Oct 1, 2021
@sebastienlagarde sebastienlagarde deleted the HDRP/hair-bsdf-validation branch October 1, 2021 08:00
sebastienlagarde added a commit that referenced this pull request Oct 1, 2021
* Add the various color parameterization modes (color, melanin, absorption). To allow easier reference matching.

* Add the BSDFData conversion to absorption

* Clean up the hair reference and add the longitudinal scattering

* Add fiber attenuations for each path

* Add the azimuthal scattering from trimmed logistic

* Compute the BSDF

* Add Hair BSDF Reference Furnace Test

* Fix many subtle issues in the reference and improve the stability of the furnace test. Test for more roughness terms

* Add importance sampling. Now matching ground truth renders

* Add some inverse absorption mappings

* Make the approximation better fit the reference

* More reference matching

* Match the dual scattering to the reference

* Various DS and preintegration fixes

* Fix near/far field reference, fix low variance nans

* Fix the azimuthal scattering preintegration

* Disable symbols, furnace test

* mend

* Revert "mend"

This reverts commit ef07fe8.

* Remove the unused common function I added

* hide the color mode for now

* Precompue all azimuthal distributions, finally fix the absorption discrepancy between reference and approximation. Now fully matching reference for Bn = 0.7!

* Remove the azimuthal scattering toggle as it's now always enabled

* Update reference images and tweak the graph to ensure we have coverage for multiple scattering

* Fix reference images for Vulkan

* Suppress all the warnings

Co-authored-by: sebastienlagarde <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.

2 participants