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

Use roughness-dependent fresnel when rendering with multiscattering #16559

Merged
merged 1 commit into from
May 28, 2019

Conversation

jsantell
Copy link
Contributor

Follow up from the multiscattering handling in PBR rendering: #15644 #15673

The fresnel was not taking into account roughness, resulting in bright fresnel that is especially noticible on rough, dark materials.

(0x000, roughness:1, metalness:0) With changes (top), and r105 (bottom):

Screenshot from 2019-05-24 18-26-43

(0x000, roughness:1, metalness:0) With changes (top), and r105 (bottom):

Screenshot from 2019-05-24 18-41-16

@@ -268,17 +279,15 @@ vec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in
// http://www.jcgt.org/published/0008/01/03/
void BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {

float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
float dotNV = max( 0.01, dot( geometry.normal, geometry.viewDir ) );
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please explain your reason for this redefinition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Idea was this should never actually be 0, but that isn't true in some projections(?), and regardless doesn't change the outcome here. Will remove.


vec3 F = F_Schlick( specularColor, dotNV );
vec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );
Copy link
Collaborator

Choose a reason for hiding this comment

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

You are passing in dotNV to your method, but the method as written expects dotLH.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Fdez-Aguera paper uses the normal vector rather than the halfway vector. Not sure if that's required, or if this should use the halfway vector like other instances. I'll do some side by side tests.

Either way, as this is a new schlick function, the signature needs to be updated. Good catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@jsantell
Copy link
Contributor Author

@robertlong Could you give this a try if you still have that hot-fresnel in Hubs?

@jsantell jsantell force-pushed the roughness-dependent-fresnel branch from af43249 to b14bbaf Compare May 26, 2019 16:07
@jsantell
Copy link
Contributor Author

Addressed comments, and trying more scenarios with the changes. This could also be a preference, with prior art of PBR models (Disney's) exposing some "fresnel" parameter that isn't based on physics. Similarly, with the previous standard shader changes in r101/ #15644, any sort of change can be unexpected.

Maybe parameterizing a fresnel value by mapping directly to the roughness dampening seems like an obvious parameter to consider if anything, although I haven't given this more thought.

Side by side comparison of change; dielectrics on top, conductors bottom, roughness 0 -> 1

three-pbr-105changes

@jsantell
Copy link
Contributor Author

jsantell commented May 26, 2019

There's also the related work of potentially reverting #15673 -- the rationale was that it produced a dark fresnel, but that could just be that scenario (there's no dark fresnel when the torus is reflecting the lighter sky, rather than distorting the dark building). This is mostly noticeable in smooth dielectrics (metalness:0,roughness:0).

Reverting that patch, along with this patch makes dielectrics energy-preserving as well (i.e. passing the furnace test), and may be preferable. This is what it looks like:

three_pbr_105-dev2

Note that this test scene is WIP, the view angles for the objects on the side are more extreme than in the middle.

I can kick this to a new issue as well

@mrdoob
Copy link
Owner

mrdoob commented May 26, 2019

Have you tried comparing how the same scene looks like in babylon.js?

@jsantell
Copy link
Contributor Author

jsantell commented May 27, 2019

Have to tried comparing how the same scene looks like in babylon.js?

Not yet, although here are some comparisons, roughness increasing rightward, metalness increasing upward in a furnace test; any visible surfaces indicate energy gain or loss:

r100

r104, with energy compensation for metals, note the top row is invisible (#15644, #15673). Note the newly hottened fresnel, especially on rough materials. This is what's currently on dev.

Reverting #15673 makes dielectrics also energy preserving however, completely hiding the row at the bottom:


Applying this patch, roughness dependent fresnel; note the reduced hotness compared to the r104 renders:

Applying this patch, on top of reverting #15673:


What is the ideal outcome, or goal? Targeting another renderer (e.g. Filament, Babylon), or manufactured tests like the furnace tests above, or by arbitrary examples in the repo? I'm not sure which one I'd even suggest. At least subjectively, this patch makes rough matte objects possible again, subduing the very hot fresnel, and matching the paper's implementation

@WestLangley
Copy link
Collaborator

#15673 does not look right, so I'd revert it.

This PR is correcting an error in a former PR, right? So, it has to be fixed -- unless you argue that the change is not perceptible (e.g., your last image above).

You may be seeing what happens when we cobble together techniques from multiple sources that do not fit together as a coherent whole.

@jsantell
Copy link
Contributor Author

jsantell commented May 28, 2019

#15673 does not look right, so I'd revert it.

The original rational was a dark fresnel in some cases, but I think that may have been due to some specific examples (and think they were correctly reflecting dark environments). // @mrdoob

This PR is correcting an error in a former PR, right? So, it has to be fixed -- unless you argue that the change is not perceptible (e.g., your last image above).

This PR is correcting the original energy compensation one by applying roughness-dependent fresnel. This patch, and the reverting are two additional changes -- when applying both (last image), the bottom row is now invisible and overall darkening for non-dielectric/metal materials (due to revert), and additionally, there is less fresnel glow (due to this patch). Right now, without either patch, the fresnel is very hot (second picture). Either of these would reduce that delta, but I believe both would be the most consistently correct in terms of furnace test at least. Handling the inbetween (0<metalness<1) values can be done with Filament's technique + LUT IIRC, but everything would be consistent with the Fdez paper with both of these.

You may be seeing what happens when we cobble together techniques from multiple sources that do not fit together as a coherent whole.

I was thinking the same thing, hence why I'm mentioning reverting #15673 at all, since they're all related. (Edit: thinking more about that especially with the newer gltf materials/Dassault specs) and wondering how that could be applied here)

@mrdoob mrdoob added this to the r105 milestone May 28, 2019
@mrdoob
Copy link
Owner

mrdoob commented May 28, 2019

Reverted #15673: 1128d60

@mrdoob mrdoob merged commit 2f054a3 into mrdoob:dev May 28, 2019
@mrdoob
Copy link
Owner

mrdoob commented May 28, 2019

Thanks!

@mrdoob
Copy link
Owner

mrdoob commented May 28, 2019

Yeah, that fresnel was a bit too much...

Before:

Screen Shot 2019-05-27 at 6 34 36 PM

After:

Screen Shot 2019-05-27 at 6 34 49 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants