-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
New Rough Radiance Approximation #16063
base: master
Are you sure you want to change the base?
New Rough Radiance Approximation #16063
Conversation
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
packages/dev/core/src/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.ts
Outdated
Show resolved
Hide resolved
@@ -1255,6 +1255,13 @@ export class PBRMaterialPropertyGridComponent extends React.Component<IPBRMateri | |||
propertyName="useHorizonOcclusion" | |||
onPropertyChangedObservable={this.props.onPropertyChangedObservable} | |||
/> | |||
<CheckBoxLineComponent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Triggering this doesn't change the shader right now. I think I'm missing something to make this property change force the shader to recompile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just replace:
if (this._useAlternateRoughRadiance) {
defines.ALTERNATE_ROUGH_RADIANCE = this._useAlternateRoughRadiance;
}
with
defines.ALTERNATE_ROUGH_RADIANCE = this._useAlternateRoughRadiance;
in pbrBaseMaterial.ts
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this ok now @MiiBond ?
Snapshot stored with reference name: Test environment: To test a playground add it to the URL, for example: https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/16063/merge/index.html#WGZLGJ#4600 Links to test babylon tools with this snapshot: https://playground.babylonjs.com/?snapshot=refs/pull/16063/merge To test the snapshot in the playground with a playground ID add it after the snapshot query string: https://playground.babylonjs.com/?snapshot=refs/pull/16063/merge#BCU1XR#0 |
Visualization tests for WebGPU (Experimental) |
WebGL2 visualization test reporter: |
9c5117a
to
c0bb1e5
Compare
Hey @MiiBond! Is there a physical argument for lerping radiance to irradiance with higher roughness values, or is it simply because the results look better? Also, have you been able to test with larger scenes / other HDR files to compare with the existing code path? |
So, the short answer is that it's not physically correct to essentially substitute diffuse reflection for specular at roughness levels near 1.0 (they aren't the same thing). However, the reason that it looks more plausible in cases like what I've shown above is that the importance sampling for radiance at roughness near 1.0 really starts to do a very poor job when an IBL has small, strong light sources. Basically, the importance sampling is centered around the reflection direction but doesn't take into account the intensity of the IBL in a given direction. So, on the rough end, you end up with a blurred reflection without the intensity of strong light sources taken into account. This is why we lose the terminators for the strong lights. We might be able to improve the filtering of radiance at the rough end using the CDF maps but I'm not sure how exactly to do that and I haven't had time to explore it.
Yes, I've been using this approximation in Substance Stager for a while now. I can post some more comparisons in a minute. |
Thanks a lot for the explanation and the screenshots! I will review the PR asap. |
Thanks a ton for the explanation !!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only a few comments!
Also, you should update the visu test and remove the UI, as it takes 1/4 of the picture.
packages/dev/core/src/Materials/Node/Blocks/PBR/reflectionBlock.ts
Outdated
Show resolved
Hide resolved
packages/dev/core/src/Materials/Node/Blocks/PBR/reflectionBlock.ts
Outdated
Show resolved
Hide resolved
packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockReflection.fx
Outdated
Show resolved
Hide resolved
packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockReflection.fx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move the new setting in PBRBRDFConfiguration.ts ? as it is really advanced ? Also, should we turn it on by default ? I quite like the visual improvment. We could revert the value to false if we consider it lowering the quality in some given cases ? And finally, is it also valid when relying on an irradiance texture instead of SH as it could have more dynamicity ?
793bdad
to
afeb399
Compare
Yes, I really like this idea. It's cleaned up the added code a fair bit and I think it makes sense to enable this by default. |
Visualization tests for WebGPU (Experimental) |
WebGL2 visualization test reporter: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The way prefiltered radiance is applied in rasterizers tends not to match the raytraced ground truth very well towards the rough end of the spectrum. I've found that mixing with the irradiance gives a much better result as you can see in the images below.
Here's a playground: http://localhost:1338/#RNO672#1
Raytraced:
Babylon: