0030700: Visualization, TKOpenGl - support PBR Metallic-Roughness shading model
[occt.git] / src / Shaders / Shaders_PBRIllumination_glsl.pxx
diff --git a/src/Shaders/Shaders_PBRIllumination_glsl.pxx b/src/Shaders/Shaders_PBRIllumination_glsl.pxx
new file mode 100644 (file)
index 0000000..d7a2760
--- /dev/null
@@ -0,0 +1,31 @@
+// This file has been automatically generated from resource file src/Shaders/PBRIllumination.glsl
+
+static const char Shaders_PBRIllumination_glsl[] =
+  "//! Calculates direct illumination using Cook-Torrance BRDF.\n"
+  "vec3 occPBRIllumination (in vec3  theView,\n"
+  "                         in vec3  theLight,\n"
+  "                         in vec3  theNormal,\n"
+  "                         in vec4  theBaseColor,\n"
+  "                         in float theMetallic,\n"
+  "                         in float theRoughness,\n"
+  "                         in float theIOR,\n"
+  "                         in vec3  theLightColor,\n"
+  "                         in float theLightIntensity)\n"
+  "{\n"
+  "  vec3 aHalf = normalize (theView + theLight);\n"
+  "  float aCosVH = max(dot(theView, aHalf), 0.0);\n"
+  "  vec3 aFresnel = occPBRFresnel (theBaseColor.rgb, theMetallic, theIOR, aCosVH);\n"
+  "  vec3 aSpecular = occPBRCookTorrance (theView,\n"
+  "                                       theLight,\n"
+  "                                       theNormal,\n"
+  "                                       theBaseColor.rgb,\n"
+  "                                       theMetallic,\n"
+  "                                       theRoughness,\n"
+  "                                       theIOR);\n"
+  "  vec3 aDiffuse = vec3(1.0) - aFresnel;\n"
+  "  aDiffuse *= 1.0 - theMetallic;\n"
+  "  aDiffuse *= INV_PI;\n"
+  "  aDiffuse *= theBaseColor.rgb;\n"
+  "  aDiffuse = mix (vec3(0.0), aDiffuse, theBaseColor.a);\n"
+  "  return (aDiffuse + aSpecular) * theLightColor * theLightIntensity * max(0.0, dot(theLight, theNormal));\n"
+  "}\n";