lib-coat.glsl
Public Functions:
iorToSpecularLevel
getCoatNormal
Import from library
Copied to your clipboardimport lib-defines.glsl
All engine parameters useful for coat.
Copied to your clipboard//: param custom {//: "group": "Coat",//: "label": "Enable",//: "default": false,//: "asm": "coat",//: "description": "<html><head/><body><p>Simulates a layer on top of the material. Used to create clear coats, lacquers, and varnishes.</p></body></html>"//: }uniform_specialization bool coatEnabled;//: param auto channel_coatopacityuniform SamplerSparse coatOpacity_tex;//: param auto channel_coatcoloruniform SamplerSparse coatColor_tex;//: param auto channel_coatroughnessuniform SamplerSparse coatRoughness_tex;//: param custom {//: "group": "Coat",//: "label": "Index of refraction",//: "min": 0.0,//: "max": 40.0,//: "default": 1.6,//: "visible": "input.coatEnabled",//: "asm": "coat_ior",//: "description": "<html><head/><body><p>The amount light bends as it passes through the coat.</p></body></html>"//: }uniform float coatIoR;//: param auto channel_coatspecularleveluniform SamplerSparse coatSpecularLevel_tex;//: param auto channel_coatnormaluniform SamplerSparse coatNormal_tex;
Import from library
Copied to your clipboardimport lib-normal.glslimport lib-sampler.glsl
Compute an f0 at the interface between to materials from their indices of refraction.
Copied to your clipboardfloat iorToSpecularLevel(float iorFrom, float iorTo){float sqrtR0 = (iorTo-iorFrom) / (iorTo+iorFrom);return sqrtR0*sqrtR0;}
Return the coat normal in world space.
Copied to your clipboardvec3 getWSCoatNormal(SparseCoord coord, vec3 tangent, vec3 bitangent, vec3 normal){vec3 tsNormal = (coatNormal_tex.is_set ?normalUnpack(textureSparse(coatNormal_tex, coord), base_normal_y_coeff) :vec3(0.0, 0.0, 1.0));return normalize(tsNormal.x * tangent +tsNormal.y * bitangent +tsNormal.z * normal);}
Compute the approximate colored coat absorption for a given view direction.
Copied to your clipboardvec3 coatPassageColorMultiplier(vec3 coatColor, float coatOpacity, float ndv){if (min(coatColor.r, min(coatColor.g, coatColor.b)) < 1.0){float power = 0.1575 / mix(0.24, 1.0, ndv * ndv) + 0.25;return pow(mix(vec3(1.0), coatColor, coatOpacity), vec3(power));}else{return vec3(1.);}}