0031275: Visualization, TKOpenGl - handle normal-map texture with Path-Tracing
[occt.git] / src / Shaders / Shaders_TangentSpaceNormal_glsl.pxx
1 // This file has been automatically generated from resource file src/Shaders/TangentSpaceNormal.glsl
2
3 static const char Shaders_TangentSpaceNormal_glsl[] =
4   "//! Calculates transformation from tangent space and apply it to value from normal map to get normal in object space\n"
5   "vec3 TangentSpaceNormal (in mat2 theDeltaUVMatrix,\n"
6   "                         in mat2x3 theDeltaVectorMatrix,\n"
7   "                         in vec3 theNormalMapValue,\n"
8   "                         in vec3 theNormal,\n"
9   "                         in bool theIsInverse)\n"
10   "{\n"
11   "  theNormalMapValue = normalize(theNormalMapValue * 2.0 - vec3(1.0));\n"
12   "  // Inverse matrix\n"
13   "  theDeltaUVMatrix = mat2 (theDeltaUVMatrix[1][1], -theDeltaUVMatrix[0][1], -theDeltaUVMatrix[1][0], theDeltaUVMatrix[0][0]);\n"
14   "  theDeltaVectorMatrix = theDeltaVectorMatrix * theDeltaUVMatrix;\n"
15   "  // Gram-Schmidt orthogonalization\n"
16   "  theDeltaVectorMatrix[1] = normalize(theDeltaVectorMatrix[1] - dot(theNormal, theDeltaVectorMatrix[1]) * theNormal);\n"
17   "  theDeltaVectorMatrix[0] = cross(theDeltaVectorMatrix[1], theNormal);\n"
18   "  float aDirection = theIsInverse ? -1.0 : 1.0;\n"
19   "  return mat3 (aDirection * theDeltaVectorMatrix[0], aDirection * theDeltaVectorMatrix[1], theNormal) * theNormalMapValue;\n"
20   "}\n";