0030700: Visualization, TKOpenGl - support PBR Metallic-Roughness shading model
[occt.git] / src / Shaders / Shaders_PBRFresnel_glsl.pxx
diff --git a/src/Shaders/Shaders_PBRFresnel_glsl.pxx b/src/Shaders/Shaders_PBRFresnel_glsl.pxx
new file mode 100644 (file)
index 0000000..3612829
--- /dev/null
@@ -0,0 +1,39 @@
+// This file has been automatically generated from resource file src/Shaders/PBRFresnel.glsl
+
+static const char Shaders_PBRFresnel_glsl[] =
+  "//! Functions to calculate fresnel coefficient and approximate zero fresnel value.\n"
+  "vec3 occPBRFresnel (in vec3  theBaseColor,\n"
+  "                    in float theMetallic,\n"
+  "                    in float theIOR)\n"
+  "{\n"
+  "  theIOR = (1.0 - theIOR) / (1.0 + theIOR);\n"
+  "  theIOR *= theIOR;\n"
+  "  vec3 f0 = vec3(theIOR);\n"
+  "  f0 = mix (f0, theBaseColor.rgb, theMetallic);\n"
+  "  return f0;\n"
+  "}\n"
+  "\n"
+  "vec3 occPBRFresnel (in vec3  theBaseColor,\n"
+  "                    in float theMetallic,\n"
+  "                    in float theIOR,\n"
+  "                    in float theCosVH)\n"
+  "{\n"
+  "  vec3 f0 = occPBRFresnel (theBaseColor, theMetallic, theIOR);\n"
+  "  theCosVH = 1.0 - theCosVH;\n"
+  "  theCosVH *= theCosVH;\n"
+  "  theCosVH *= theCosVH * theCosVH * theCosVH * theCosVH;\n"
+  "  return f0 + (vec3 (1.0) - f0) * theCosVH;\n"
+  "}\n"
+  "\n"
+  "vec3 occPBRFresnel (in vec3  theBaseColor,\n"
+  "                    in float theMetallic,\n"
+  "                    in float theRoughness,\n"
+  "                    in float theIOR,\n"
+  "                    in float theCosV)\n"
+  "{\n"
+  "  vec3 f0 = occPBRFresnel (theBaseColor, theMetallic, theIOR);\n"
+  "  theCosV = 1.0 - theCosV;\n"
+  "  theCosV *= theCosV;\n"
+  "  theCosV *= theCosV * theCosV * theCosV * theCosV;\n"
+  "  return f0 + (max(vec3(1.0 - theRoughness), f0) - f0) * theCosV;\n"
+  "}\n";