0030640: Visualization, Graphic3d_Camera - add option creating Projection matrix...
[occt.git] / src / Shaders / PBRFresnel.glsl
CommitLineData
67312b79 1//! Functions to calculate fresnel coefficient and approximate zero fresnel value.
2vec3 occPBRFresnel (in vec3 theBaseColor,
3 in float theMetallic,
4 in float theIOR)
5{
6 theIOR = (1.0 - theIOR) / (1.0 + theIOR);
7 theIOR *= theIOR;
8 vec3 f0 = vec3(theIOR);
9 f0 = mix (f0, theBaseColor.rgb, theMetallic);
10 return f0;
11}
12
13vec3 occPBRFresnel (in vec3 theBaseColor,
14 in float theMetallic,
15 in float theIOR,
16 in float theCosVH)
17{
18 vec3 f0 = occPBRFresnel (theBaseColor, theMetallic, theIOR);
19 theCosVH = 1.0 - theCosVH;
20 theCosVH *= theCosVH;
21 theCosVH *= theCosVH * theCosVH * theCosVH * theCosVH;
22 return f0 + (vec3 (1.0) - f0) * theCosVH;
23}
24
25vec3 occPBRFresnel (in vec3 theBaseColor,
26 in float theMetallic,
27 in float theRoughness,
28 in float theIOR,
29 in float theCosV)
30{
31 vec3 f0 = occPBRFresnel (theBaseColor, theMetallic, theIOR);
32 theCosV = 1.0 - theCosV;
33 theCosV *= theCosV;
34 theCosV *= theCosV * theCosV * theCosV * theCosV;
35 return f0 + (max(vec3(1.0 - theRoughness), f0) - f0) * theCosV;
36}