 //     https://github.com/KhronosGroup/glTF-WebGL-PBR/#environment-maps
 // [4] "An Inexpensive BRDF Model for Physically based Rendering" by Christophe Schlick
 //     https://www.cs.virginia.edu/~jdl/bib/appearance/analytic%20models/schlick94b.pdf
+// [5] "KHR_materials_clearcoat"
+//     https://github.com/ux3d/glTF/tree/KHR_materials_pbrClearcoat/extensions/2.0/Khronos/KHR_materials_clearcoat
 
 
 precision highp float;

uniform float u_AlphaCutoff;
#endif

uniform vec3 u_Camera;

uniform int u_MipCount;

        // Calculation of analytical lighting contribution
        vec3 diffuseContrib = (1.0 - F) * diffuse(materialInfo);
        vec3 specContrib = F * Vis * D;

        //apply clearcoat only if clearcoatFactor > 0
        if(u_ClearcoatFactor > 0.0)
        {
            vec3 clearcoatContrib = specContrib;
            vec3 factor0 = (1.0 - u_ClearcoatFactor * fresnel(vec3(0.04), angularInfo.NdotV)) * (1.0 - u_ClearcoatFactor * fresnel(vec3(0.04), angularInfo.NdotL));
            vec3 factor1 = u_ClearcoatFactor * fresnel(vec3(0.04), angularInfo.VdotH);
            return angularInfo.NdotL * ((diffuseContrib + specContrib) * factor0 + clearcoatContrib * factor1);
        }

        // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)
        return angularInfo.NdotL * (diffuseContrib + specContrib);
