Skip to content

Conversation

anisunity
Copy link
Contributor

@anisunity anisunity commented Sep 8, 2021

https://fogbugz.unity3d.com/f/cases/1352424/
A double contribution of the clear cloat was found when SSR/RTR was enabled on the Lit and Stack Lit shader. This fixes that behavior.

Testing status.
The solution was validated by the user.
Multiple tests will need screenshot updates

@github-actions
Copy link

github-actions bot commented Sep 8, 2021

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

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.

@anisunity anisunity marked this pull request as ready for review September 9, 2021 09:49
@anisunity anisunity requested a review from a team September 9, 2021 09:49
Copy link
Contributor

@TomasKiniulis TomasKiniulis 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 assuming updated reference images pass, since it's already validated by user.

@anisunity anisunity changed the title Initial SSR clear coat improvement SSR clear coat improvement Sep 9, 2021
@anisunity
Copy link
Contributor Author

Fixed formatting and launching yamato

@patrickp-unity3d
Copy link
Contributor

patrickp-unity3d commented Sep 9, 2021

@anisunity, @slunity should this fix also be applied to AxF?

@sebastienlagarde
Copy link
Contributor

Added Stephane for awareness

@anisunity
Copy link
Contributor Author

An other solution to avoid the inout would be to add a parameter, but that would mean breaking the shader api... so

@sebastienlagarde
Copy link
Contributor

An other solution to avoid the inout would be to add a parameter, but that would mean breaking the shader api... so

yeah, was afraid that inout may currently braek the API but it doesn, we will go with it. Don't like it too much but I haven't better alternative to propose without breaking the API so let's use that

@sebastienlagarde
Copy link
Contributor

There is various failure with Stacklit on test apparently

@anisunity
Copy link
Contributor Author

Checking that

@patrickp-unity3d
Copy link
Contributor

Looking at AxF.hlsl, it really looks like the fix should be done there too

@anisunity
Copy link
Contributor Author

Fixed stack lit, relaunching the tests

@sebastienlagarde
Copy link
Contributor

there is still one test failing: 1302_StackLitSG_PixarLM.png

@anisunity
Copy link
Contributor Author

After looking at the screenshots, the new screenshots make more sense than the previous ones. Updating them.

@sebastienlagarde sebastienlagarde merged commit f35677c into master Sep 20, 2021
@sebastienlagarde sebastienlagarde deleted the HDRP/clear-cloat-ssr branch September 20, 2021 12:53
sebastienlagarde pushed a commit that referenced this pull request Sep 20, 2021
slunity added a commit that referenced this pull request Oct 21, 2021
Add support for more refined reflection hierarchy for SSR-RTR blending with IBL and to avoid double coat lighting.
This is mainly based on #4968, but with the added feature to re-use the coat-traced light for similarly-rough bottom layer lobes, like done for Lit.

This fixes several issues in the implementation in StackLit since #5565:

-Similar issues fixed for Lit (see other PR for Lit)
-StackLit can have a rough coat, but an arbitrary 0.9 smoothness value was used to decide if the coat-traced light would be re-used for the bottom lobes.
-The wrong bottom lobe roughnesses were used (values that don't include the effect of BRDF vertical layering computations)
-StackLit can have different lobe directions and the light hierarchy now account for this.
slunity added a commit that referenced this pull request Oct 21, 2021
…lback when a coat is present:

1)
SSR lighting was applied using the coatMask in such a way that the bottom layer incorrectly gained coat-traced light as the coatMask went to 0, even prior #5565.
#5565 added the usage of the coat lighting (irrespective of coatMask considerations, ie even when coatMask = 1) when the bottom layer has a roughness close enough to 0, ie to that of the coat lobe for which we traced the indirect light.
However, even when the bottom layer roughess was very different (blendFactor = 1), coatMask could escape that logic as it went to 0.
(In that case, the comment in the code "// On top of this above we also add an additional hack to limit the smoothness used on based layer depending on coat layer for SSR application (See below)" was wrong)

2)
The reflectionHierarchyWeight (again even before #5565) was incorrectly including an F term, while the consumed / used-up light hierarchy weight is orthogonal
to the specific material shading details (reflectance factors, ie pre-integrated FGD or coatF here).
So regardless of if we used the ssr coat lighting for the bottom layer, as coatF grew, we would artificially remove total bottom layer light at grazing angles.
Ergo, this was incorrectly darkening the grazing angle fresnel reflection because of darkening of the bottom layer.

Moreover, with the separate coat hierarchy weight, the envlighting can no longer use the same probe volume intersection weight, and a separate update and capping must be done for the coat reflection hierarchy.

3)
In #5565, the code states we lerp-in coat light contribution for the bottom layer when its smoothness is above 0.9 and lerp-out from 0.9 to 0.8,
but the code was actually fading from 0.9 to 0.7, not 0.8. I assumed the code behavior was desired (since probably eyeballed) and used the same ranges but made the code cleaner.

4)
More importantly (vs 3), the behavior since #5565 could actually erroneously eliminate the coat lobe and use only the bottom lobe with the coat-traced light: this happened when the bottom roughness was close
to the coat roughness, as in that case we had a "blendfactor" that would lerp from coat F to bottom FGD, instead of actually combining both lobes with their respective wanted contributions.
sebastienlagarde added a commit that referenced this pull request Nov 22, 2021
…ith IBL fallback (case 1380351) (#6106)

* Coat SSR-RTR: Fix various issues with using SSR lighting with IBL fallback when a coat is present:

1)
SSR lighting was applied using the coatMask in such a way that the bottom layer incorrectly gained coat-traced light as the coatMask went to 0, even prior #5565.
#5565 added the usage of the coat lighting (irrespective of coatMask considerations, ie even when coatMask = 1) when the bottom layer has a roughness close enough to 0, ie to that of the coat lobe for which we traced the indirect light.
However, even when the bottom layer roughess was very different (blendFactor = 1), coatMask could escape that logic as it went to 0.
(In that case, the comment in the code "// On top of this above we also add an additional hack to limit the smoothness used on based layer depending on coat layer for SSR application (See below)" was wrong)

2)
The reflectionHierarchyWeight (again even before #5565) was incorrectly including an F term, while the consumed / used-up light hierarchy weight is orthogonal
to the specific material shading details (reflectance factors, ie pre-integrated FGD or coatF here).
So regardless of if we used the ssr coat lighting for the bottom layer, as coatF grew, we would artificially remove total bottom layer light at grazing angles.
Ergo, this was incorrectly darkening the grazing angle fresnel reflection because of darkening of the bottom layer.

Moreover, with the separate coat hierarchy weight, the envlighting can no longer use the same probe volume intersection weight, and a separate update and capping must be done for the coat reflection hierarchy.

3)
In #5565, the code states we lerp-in coat light contribution for the bottom layer when its smoothness is above 0.9 and lerp-out from 0.9 to 0.8,
but the code was actually fading from 0.9 to 0.7, not 0.8. I assumed the code behavior was desired (since probably eyeballed) and used the same ranges but made the code cleaner.

4)
More importantly (vs 3), the behavior since #5565 could actually erroneously eliminate the coat lobe and use only the bottom lobe with the coat-traced light: this happened when the bottom roughness was close
to the coat roughness, as in that case we had a "blendfactor" that would lerp from coat F to bottom FGD, instead of actually combining both lobes with their respective wanted contributions.

* Update CHANGELOG.md

Co-authored-by: sebastienlagarde <sebastien@unity3d.com>
sebastienlagarde added a commit that referenced this pull request Nov 22, 2021
Add support for more refined reflection hierarchy for SSR-RTR blending with IBL and to avoid double coat lighting.
This is mainly based on #4968, but with the added feature to re-use the coat-traced light for similarly-rough bottom layer lobes, like done for Lit.

This fixes several issues in the implementation in StackLit since #5565:

-Similar issues fixed for Lit (see other PR for Lit)
-StackLit can have a rough coat, but an arbitrary 0.9 smoothness value was used to decide if the coat-traced light would be re-used for the bottom lobes.
-The wrong bottom lobe roughnesses were used (values that don't include the effect of BRDF vertical layering computations)
-StackLit can have different lobe directions and the light hierarchy now account for this.

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.

4 participants