3
$\begingroup$

I'm trying to integrate the thin-film interference effect described in the paper "Belcour, L., & Barla, P. (2017). A practical extension to microfacet theory for the modeling of varying iridescence." (https://hal.archives-ouvertes.fr/hal-01518344/document) into my material model, which is based on google/Filament's material model (https://google.github.io/filament/Filament.md.html).

However I'm having trouble trying to understand the way to add them together. Let's say I'm shading a pixel, direct lighting goes like this:

vec3 Fr = specularLobe();   // D * F * V
vec3 Fd = diffuseLobe();    // 1 / PI * diffuseColor

return (Fd + Fr) * light.color * light.attenuation * NoL;

And on the other side, indirect lighting goes like this...

vec3 Fd = diffuseIrradiance() * diffuseColor;
vec3 Fr = specularIrradiance() * DFG();

return (Fd + Fr);

Now, if I want to add the thin film/iridescence layer on top of the base material, in what way does it take into account to bottom layer for all the lighting?

I've been looking at this implementation in UE4 (https://polycount.com/discussion/comment/2604578#Comment_2604578), but they seem to input the result of the BRDF calculation directly into the 'Base Color' of the material, which I really don't think it is what I'm looking for, correct me if I'm wrong...

UE4-editor-example

In this other implementation in Unity (https://github.com/Xerxes1138/Iridescence/blob/master/Iridescence.shader) they seem to account for iridescence in both IBL and direct lighting separately, but the layer base is not taken much into account as far as I know.

Finally, in the paper itself, the following statement is made:

Our extension consists in replacing the classic Fresnel reflectance term, F , by a more complex term, R accounting for all inter-reflections inside the thin-film layer, including constructive and destructive interference effects.

From this I understand that simply by replacing the Fresnel Reflectance with the Airy Reflectance function should do the trick, but again, I'm not sure which would be the appropriate approach to being as physically correct as possible.

(The original supp-code from the paper can be obtained from: https://hal.inria.fr/hal-01518344v2/file/supplemental-code%20%282%29.zip)

Thanks for the help!

$\endgroup$
3
$\begingroup$

Unfortunately, the iridescence model is not made to be applied to a diffuse term. Pascal and I made it for microfacet models only (that is the specular term).

One way to understand how to include it to a game engine might be to look at Unity's HDRP implementation.

In the Lit.hlsl to see how to incorporate the iridescence Fresnel into a specular + diffuse BRDF:

https://github.com/Unity-Technologies/ScriptableRenderPipeline/blob/master/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl

PreLightData GetPreLightData(float3 V, PositionInputs posInput, inout BSDFData bsdfData) {

    [...]

    if (bsdfData.iridescenceMask > 0.0)
    {
        bsdfData.fresnel0 = lerp(bsdfData.fresnel0, EvalIridescence(topIor, viewAngle, bsdfData.iridescenceThickness, bsdfData.fresnel0), bsdfData.iridescenceMask);
    }
}

See the implementation of the EvalIridescence in BSDF.hlsl:

https://github.com/Unity-Technologies/ScriptableRenderPipeline/blob/30f1b16c8094ca133c165e56380ebb7ab9e7c0d9/com.unity.render-pipelines.core/ShaderLibrary/BSDF.hlsl

What they are doing is to blend the standard Fresnel term with the iridescence one based on a iridescence mask value.

I hope this is helpfull.

$\endgroup$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.