blob: 555e461bb595664bc24ae40fd4c28eb2e29148e1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef FRESNEL_GLSLLIB
#define FRESNEL_GLSLLIB 1
float qt_schlick(float value)
{
float n = 1.0 - value;
float n2 = n * n;
return n2 * n2 * n;
}
vec3 qt_F0_ior(float ior, float metalness, vec3 baseColor)
{
float f0 = ((ior - 1.0) * (ior - 1.0)) / ((ior + 1.0) * (ior + 1.0));
return (vec3(f0) * (1.0 - metalness)) + (baseColor * metalness);
}
vec3 qt_principledMaterialFresnel(in vec3 N, in vec3 viewDir, in vec3 f0, in float roughness, in float fresnelPower)
{
float nDotV = clamp(dot(N, viewDir), 0.0, 1.0);
vec3 F = f0 + (max(vec3(1.0 - roughness), f0) - f0) * pow(1.0 - nDotV, fresnelPower);
return F;
}
#endif
|