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 extension branch. #1740

Conversation

UX3D-nopper
Copy link
Contributor

No description provided.

@emackey
Copy link
Member

emackey commented Jan 17, 2020

Thanks Norbert.

Acknowledgments, Overview, and Appendix all say TODO. Who is the right person to get these fleshed out?

@UX3D-nopper
Copy link
Contributor Author

Thanks Norbert.

Acknowledgments, Overview, and Appendix all say TODO. Who is the right person to get these fleshed out?

It was explicitly wanted, that the 3D formats group is doing this. Actually, as Alexey is the specification master, maybe outreach to him.

@proog128
Copy link
Contributor

Thanks for splitting #1677.

Would be great if we could add a bit more detail about how the clearcoat BRDF looks like and how layering works. I tried to sketch something which fits the rewrite of Appendix B of the main spec (#1717). Feel free to add it to the PR or tell me if you want me to open a PR against the ux3d repo.

Clearcoat

....

The clearcoat layer is applied on top of the metallic-roughness material including emission and all extensions as follows, resulting in the coated material.

coated_material = fresnel_coat(
  layer = clearcoat_brdf,
  base = material,
  ior = 1.5,
  weight = clearcoat)

material = mix(dielectric_brdf, metal_brdf, metallic)
clearcoat_brdf = specular_brdf(clearcoatRoughness^2)

The fresnel_coat operator adds a BRDF as a layer on top of another BSDF according to weight and a Fresnel term. The layer is weighted with weight*fresnel(ior). The base is weighted with 1-(weight*fresnel(ior). The index of refraction is set to a fixed value of 1.5, corresponding to a F0 value of 0.04. The clearcoat effect is modeled via a microfacet-based BRDF. Similar to the specular component of the base material, the roughness clearcoatRoughness is squared to make it perceptually linear.

Implementation

This section is non-normative.

The reflection at the coating layer is modeled as a microfacet BRDF with GGX distribution and Smith height-correlated masking-shadowing term (Heitz 2014: Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs).

     1            alpha^2
D = -- --------------------------------
    pi   (HdotN^2 * (alpha^2-1) + 1)^2

                                           2 * NdotV * NdotL
G = ----------------------------------------------------------------------------------------------
    NdotL * sqrt(NdotV^2 * (1-alpha^2) + alpha^2) + NdotV * sqrt(NdotL^2 * (1-alpha^2) + alpha^2))


                         G * D
microfacet_brdf = --------------------
                    4 * NdotL * NdotV

clearcoat_brdf = microfacet_brdf(alpha)

Light that is not reflected by the clearcoat BRDF is transmitted through the coating layer to the underlying material. The ratio of reflection to transmission is given by the Fresnel term. For an index of refraction of 1.5 Schlick's approximation is accurate and a lot easier to compute than the full Fresnel equations. Using the half vector H = normalize(V+L) the mixing is given as follows:

fresnel(cosTheta) = 0.04 + 0.96 * (1 - cosTheta)^5
clearcoat_brdf * clearcoat * fresnel(HdotV) + material * (1 - clearcoat * max(fresnel(VdotN), fresnel(LdotN)))

Note that this simple model ignores effects like internal reflection, absorption, and thin-film interference.

In some rendering algorithms it may be hard to use LdotN in the base layer weight. In this case, the term may be omitted, violating the reciprocity principle.

@proog128
Copy link
Contributor

Forgot to mention, the text above is basically a replacement for the paragraphs that define f_clearcoat (from "The clearcoat formula f_clearcoat is the same as ..." to "f = f_emissive + f_diffuse + f_specular").

It changes the equations a bit to make it reciprocal (VdotN and LdotN are now both part of the base weight), but in the end it permits to drop LdotN (which results in exactly the same math as before).

@bhouston
Copy link
Contributor

bhouston commented Feb 7, 2020

This is a great extension. The parameters as defined are just great.

@emackey
Copy link
Member

emackey commented Feb 7, 2020

At the last meeting, Alex Wood and I offered to update the Overview section and try to polish this up enough for merge.

But I was unable to push to the UX3D repo, so I had to move the branch into the main repo here. Therefore I must close this PR, and ask everyone to continue the conversation in #1756. Thanks @UX3D-nopper and everyone who has contributed here, please see the updates in #1756.

@emackey emackey closed this Feb 7, 2020
@UX3D-nopper UX3D-nopper deleted the extensions/KHR_materials_clearcoat branch July 11, 2022 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants