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

KHR_materials_clearcoat Fresnel should not influence material emission #2396

Open
droettger opened this issue May 7, 2024 · 4 comments
Open

Comments

@droettger
Copy link

The clearcoat layer is on top of emission in the layering stack. Consequently, the emission is darkened by the Fresnel term.
coated_emission = emission * (0.04 + (1 - 0.04) * (1 - NdotV)^5)

Thought experiment:
You have an emissive glass sphere with IOR 1.5 and add an infinitely thin white clearcoat with IOR 1.5 on top of it.
What changes? Nothing. The resulting image should be exactly the same.

There is no vacuum to clearcoat boundary beneath the clearcoat surface, so any emitted light from that surface should not be affected at all by the clearcoat Fresnel, no matter what the base material is.

The clearcoat would potentially just add reflections from other lights with the Fresnel between the surrounding medium (usually vacuum) and the hardcoded IOR of 1.5 of the clearcoat. Only the weighting of the base material BSDF under the clearcoat layer is affected by that Fresnel.
(If the KHR_materials_clearcoat had specified a color, that would affect the emission, but as long as the clearcoat is white and infinitely thin, it should not block light emissions in any way.

@emackey
Copy link
Member

emackey commented Jun 3, 2024

This issue has been the subject of some offline discussion in the PBR TSG lately. The short explanation is, we know we don't do a great job of dealing with IOR differences between material layers. Many glTF renderers completely ignore IOR between internal layer boundaries, and we don't do anything to explicitly disallow that.

However, the question at hand in this issue is about an external boundary, not internal: Light has been emitted from deeper inside the material, and is attempting to exit via the clearcoat layer. In the real world, a clearcoat layer would have some nonzero thickness, and there would be a crossing from inside the clearcoat to the external world, which is an IOR 1.5 to 1.0 crossing.

This means there would be an angle of total internal reflection, where emitted light could not escape near the Fresnel edges. This darkens the perceived amount of emission along those edges. So I think that might be the motivation to keep this equation.

@rsahlin
Copy link

rsahlin commented Jun 10, 2024

I agree with @droettger and would say that we have a bug in the sampleviewer implementation (and present in webviewers I tested)

1: Light hits the clearcoat interface - here we will have reflectance (specular) according to the Fresnel equations.
[Using the clearcoat roughness, possible clearcoat normal and assume IOR of 1.5]
2: The light that is not reflected (1.0 - coatreflection) will enter the base layer interface - BUT since there is no change of IOR there will be no additional specular contribution from this layer. Only refracted/transmitted (what glTF calls the diffuse contribution)

This is not what you will see if you look at, for instance, the ClearCoatTest.glb
Here you will see that both the specular factor from the coat and the base layer are present:
image

This is what it should look like - here you can clearly see that the reflections from the base layer are not present in the "coat" columns.

image

@rsahlin
Copy link

rsahlin commented Jun 10, 2024

@emackey Regarding critical angle/total internal reflection.

This means there would be an angle of total internal reflection, where emitted light could not escape near the Fresnel edges. This darkens the perceived amount of emission along those edges. So I think that might be the motivation to keep this equation.

The effect would actually be much less visible than expected - this is because as light enters the clearcoatlayer it will refract.
This refraction will decrease the angle if incidence (inside the clearcoat layer)
Thus, as light bounces off the base-layer it will be less likely to be exceed the critical angle.
This is a common effect and happens for instance in glass windows

However - I belive this is a separate issue and not related to the cancellation of specular contribution on the base layer (since the air/media interface already is handled in the coat layer)

@droettger
Copy link
Author

droettger commented Jun 10, 2024

In the real world, a clearcoat layer would have some nonzero thickness, and there would be a crossing from inside the clearcoat to the external world, which is an IOR 1.5 to 1.0 crossing.

While I can agree with the total internal reflection of emissions from materials with a thick clear coat (medium with IOR 1.5 to vacuum boundary) for purely specular cases, that is not what the discussion inside the KHR_materials_clearcoat says:
The clearcoat layer is assumed to be infinitely thin. There is no refraction.
and that was what triggered this issue. So that discussion would need to be updated with a better reasoning.

The updated condensed representation of the emission modulation
coated_emission = emission * (1 - clearcoat * clearcoat_fresnel)
is making it even clearer that this is using the inverse of the Fresnel between vacuum and IOR 1.5 and I would not expect that to be the same as the Fresnel from the other side due to TIR. Also when thinking about thick clearcoat, there would be multi-scattering effects then which would reduce that modulation esp. for rougher clearcoats.
I would need to build that as real geometry in another renderer to check that gut feeling but that has low priority for me.

I'm not so much concerned about lighting from the outside. There is no multi-scattering with an infinitely thin clearcoat.
For comparisons, this is how that ClearCoatTest.glb looks in my global illumination ray tracer implementation:
ClearCoatTest
(The only real issue I have with that are the black areas due to stopped continuation rays below the geometric surface on the clearcoat normal map in the last row's middle image which would require dynamic normal adjustments to prevent that loss of energy.)

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

No branches or pull requests

3 participants