LYGIA Shader Library

fresnel (lygia/v1.1.6/lighting/fresnel)

resolve fresnel coeficient

Dependencies:

Use:

<float|vec3> fresnel(const <float|vec3> f0, <float> NoV)

Check it on Github



#ifndef FNC_FRESNEL
#define FNC_FRESNEL

vec3 fresnel(vec3 f0, vec3 normal, vec3 view) {
   return schlick(f0, 1.0, dot(view, normal));
}

vec3 fresnel(const in vec3 f0, const in float NoV) {
#if defined(TARGET_MOBILE) || defined(PLATFORM_RPI)
    return schlick(f0, 1.0, NoV);
#else
    float f90 = saturate(dot(f0, vec3(50.0 * 0.33)));
    return schlick(f0, f90, NoV);
#endif
}

float fresnel(const in float f0, const in float NoV) {
    return schlick(f0, 1.0, NoV);
}
#endif

Dependencies:

Use:

<float3> fresnel(const <float3> f0, <float> LoH)
<float3> fresnel(<float3> _R, <float3> _f0, <float> _NoV)

Check it on Github




#ifndef FNC_FRESNEL
#define FNC_FRESNEL

float3 fresnel(const float3 f0, float LoH) {
#if defined(TARGET_MOBILE) || defined(PLATFORM_RPI)
    return schlick(f0, 1.0, LoH);
#else
    float f90 = saturate(dot(f0, float3(50.0, 50.0, 50.0) * 0.33));
    return schlick(f0, f90, LoH);
#endif
}

// float fresnelf(float3 V, float3 N, float R0) {
//     float cosAngle = 1.0-max(dot(V, N), 0.0);
//     float result = cosAngle * cosAngle;
//     result = result * result;
//     result = result * cosAngle;
//     result = clamp(result * (1.0 - R0) + R0, 0.0, 1.0);
//     return result;
// }

#endif

LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.

Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).

It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.

Get the latest news and releases

Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository