-
Notifications
You must be signed in to change notification settings - Fork 407
glTF PBR Clearcoat interaction with Emission #2641
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
Open
bowald
wants to merge
3
commits into
AcademySoftwareFoundation:main
Choose a base branch
from
bowald:gltf-clearcoat-emission-interaction
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This looks like a thoughtful implementation of the Fresnel effect of the coating, though I wonder if we could leverage the standard
generalized_schlick_edfnode instead:https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/documents/Specification/MaterialX.PBRSpec.md#node-generalized-schlick-edf
Uh oh!
There was an error while loading. Please reload this page.
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.
I agree, that was my first idea, and use
multiply_edfCwith theemission_coloror pipe theuniform_edfinto the base-input.But there are some implementation details of
generalize_schlickthat I think differ from the gltf_spec formula, as well as not allowing me to supply the normal (as it needs to be the clearcoat normal).This is the fresnel described by the glTF spec, KHR_materials_clearcoat.
In the mx_generalized_schlick_edf glsl implementation it seems that NdoV is clamped and not the absolute value.
also the mx_fresnel_schlick function in glsl uses
mixwith the arguments in another order then expected for clearcoat interaction.According to GLSLangSpec.4.40.pdf, page 146, this is the definition of mix :
to be equalent to glTF implementation the mix should be called with
I should say that I havn't tested the code (because I couldn't figure out how to supply the clearcoat normal to the edf func).
Uh oh!
There was an error while loading. Please reload this page.
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.
Regarding the use of
clampvsabsas in the spec. It seems like the gltf-sample-renderer usesclamphere as well and notabsas in the spec. Code reference. So that may not be an issue.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.
Also realized that there is a
Standard Schlick Fresnelin the mx_microfacet lib. That is what I'm after, it will sort out the "mix"-problem I wrote about in an earlier reply. But I cannot see a way to access it fromgeneralized_schlick_edf, is that possible?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.
All good points, @bowald, and I'm CC'ing @niklasharrysson for his expertise with the definition and implementation of
generalized_schlick_edf.Our original goal for the
generalized_schlick_edfnode was to handle the very situation you've encountered here, where the shape of an EDF lobe is influenced by the clearcoat layer above it, so if there are limitations in our current definition I'm hoping we can address them to encompass the needs ofgltf_pbras well.As a second reference point, here's where we use
generalized_schlick_edfin the definition ofstandard_surfaceto handle a similar situation:https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/libraries/bxdf/standard_surface.mtlx#L399