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

Clearcoat renders Fresnel reflectance on both coat and base layer. #546

Open
rsahlin opened this issue Jun 11, 2024 · 5 comments
Open

Clearcoat renders Fresnel reflectance on both coat and base layer. #546

rsahlin opened this issue Jun 11, 2024 · 5 comments

Comments

@rsahlin
Copy link

rsahlin commented Jun 11, 2024

As clearcoat is an additional layer (with IOR 1.5) that light interacts with prior to interaction with the base-layer, there shall be no Fresnel reflection in the base-layer (unless material uses IOR extension).

The below image is from ClearCoatTest.glb in the sample asset repo:
image

Compare 'Base layer' and 'Coated' columns and you will see that the reflection from the 'Base layer' are still present when using clearcoat.

Instead it should look like this - here you can see that the reflection from the 'Base layer' is not present in the coated versions.

image

@rsahlin rsahlin added the bug label Jun 11, 2024
@rsahlin
Copy link
Author

rsahlin commented Jun 25, 2024

I created a new version of the clearcoat test model, adding a column where the base material uses IOR = 2.0
This is to show that we can get the fresnel reflection from both the clearcoat and base layer using glTF extensions.

Now we just need to adapt the ior extension to allow setting the refractive index on metals as well.
I really see no reason why not.

image

@rsahlin
Copy link
Author

rsahlin commented Jun 25, 2024

And here is the adapted clearcoattest glb with an added column using the ior extension.

ClearCoatTestIOR.zip

@proog128
Copy link

The sample viewer probably is following the (non-normative) implementation recommendations in KHR_materials_clearcoat. This implementation has some limitations, in particular:

The index of refraction of clearcoat and base layer do not influence each other. The Fresnel terms are computed independently. source

The implementation details described in ADOBE_materials_clearcoat_specular will not solve this issue right away, because it only affects the clearcoat Fresnel. However, we would require the base layer Fresnel to take the clearcoat IOR into account (clearcoat/base interface). As you explained, this is actually the more physically correct behavior.

The downside of this approach is that it is comptutationally more expensive: it requires the base Fresnel to be evaluated twice, because we now have to blend between a base layer with clearcoat on top and a base layer without clearcoat on top, based on the clearcoat strength.

@rsahlin
Copy link
Author

rsahlin commented Jul 16, 2024

Well, either way it is a material property that is only calculated once per material based on IOR values.

  • First, the clearcoat IOR which is the interface between air and clearcoat:
    (1.5 - 1.0) / (1.5 + 1.0) ^2
  • Second, the baselayer IOR, which is the interface between clearcoat and baselayer and depends on the material IOR:
    (IOR - 1.5) / (IOR + 1.5) ^2

The reflectivity factor is calculated using the Schlick approximation and is really fast, fixing this will not have an impact on performance.
It is important that the sample-viewer is using physically correct calculations!

@UX3D-haertl
Copy link
Contributor

Currently we always follow the spec implementation sections. If we want to use a more sophisticated version we need to clarify that this is not following the spec description. From my point of view it would make more sense to first add the described method as an alternative implementation in the clearcoat readme and updated sample viewer afterwards accordingly.

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

No branches or pull requests

4 participants