0027256: Visualization, Path Tracing - add support of alpha-channel of texture
[occt.git] / src / Shaders / Shaders_PathtraceBase_fs.pxx
index 527a49e..187e127 100644 (file)
@@ -762,10 +762,16 @@ static const char Shaders_PathtraceBase_fs[] =
   "      aTexCoord.st = vec2 (dot (aTrsfRow1, aTexCoord),\n"
   "                           dot (aTrsfRow2, aTexCoord));\n"
   "\n"
-  "      vec3 aTexColor = textureLod (\n"
-  "        sampler2D (uTextureSamplers[int (aMaterial.Kd.w)]), aTexCoord.st, 0.f).rgb;\n"
+  "      vec4 aTexColor = textureLod (\n"
+  "        sampler2D (uTextureSamplers[int (aMaterial.Kd.w)]), aTexCoord.st, 0.f);\n"
   "\n"
-  "      aMaterial.Kd.rgb *= aTexColor * aTexColor; // de-gamma correction (for gamma = 2)\n"
+  "      aMaterial.Kd.rgb *= (aTexColor.rgb, aTexColor.rgb) * aTexColor.w; // de-gamma correction (for gamma = 2)\n"
+  "\n"
+  "      if (aTexColor.w != 1.0f)\n"
+  "      {\n"
+  "        // mix transparency BTDF with texture alpha-channel\n"
+  "        aMaterial.Kt = (UNIT - aTexColor.www) + aTexColor.w * aMaterial.Kt;\n"
+  "      }\n"
   "    }\n"
   "#endif\n"
   "\n"