0031096: Visualization, TKOpenGl - support metallic-roughness texture mapping
[occt.git] / src / Shaders / Shaders_DeclarationsImpl_glsl.pxx
1 // This file has been automatically generated from resource file src/Shaders/DeclarationsImpl.glsl
2
3 static const char Shaders_DeclarationsImpl_glsl[] =
4   "\n"
5   "//! @file DeclarationsImpl.glsl includes implementation of common functions and properties accessors\n"
6   "#if defined(FRAGMENT_SHADER)\n"
7   "//! Output color (and coverage for accumulation by OIT algorithm).\n"
8   "void occSetFragColor (in vec4 theColor)\n"
9   "{\n"
10   "#if defined(OCC_ALPHA_TEST)\n"
11   "  if (theColor.a < occAlphaCutoff) discard;\n"
12   "#endif\n"
13   "#if defined(OCC_WRITE_WEIGHT_OIT_COVERAGE)\n"
14   "  float aWeight     = theColor.a * clamp (1e+2 * pow (1.0 - gl_FragCoord.z * occOitDepthFactor, 3.0), 1e-2, 1e+2);\n"
15   "  occFragCoverage.r = theColor.a * aWeight;\n"
16   "  occFragColor      = vec4 (theColor.rgb * theColor.a * aWeight, theColor.a);\n"
17   "#else\n"
18   "  occFragColor = theColor;\n"
19   "#endif\n"
20   "}\n"
21   "#endif\n"
22   "\n"
23   "#if defined(THE_MAX_LIGHTS) && (THE_MAX_LIGHTS > 0)\n"
24   "// arrays of light sources\n"
25   "uniform               vec4  occLightSources[THE_MAX_LIGHTS * 4];  //!< packed light sources parameters\n"
26   "uniform THE_PREC_ENUM ivec2 occLightSourcesTypes[THE_MAX_LIGHTS]; //!< packed light sources types\n"
27   "#endif\n"
28   "\n"
29   "#if defined(THE_IS_PBR)\n"
30   "vec3 occDiffIBLMap (in vec3 theNormal)\n"
31   "{\n"
32   "  vec3 aSHCoeffs[9];\n"
33   "  for (int i = 0; i < 9; ++i)\n"
34   "  {\n"
35   "    aSHCoeffs[i] = occTexture2D (occDiffIBLMapSHCoeffs, vec2 ((float(i) + 0.5) / 9.0, 0.0)).rgb;\n"
36   "  }\n"
37   "  return aSHCoeffs[0]\n"
38   "\n"
39   "       + aSHCoeffs[1] * theNormal.x\n"
40   "        + aSHCoeffs[2] * theNormal.y\n"
41   "        + aSHCoeffs[3] * theNormal.z\n"
42   "\n"
43   "        + aSHCoeffs[4] * theNormal.x * theNormal.z\n"
44   "        + aSHCoeffs[5] * theNormal.y * theNormal.z\n"
45   "        + aSHCoeffs[6] * theNormal.x * theNormal.y\n"
46   "\n"
47   "        + aSHCoeffs[7] * (3.0 * theNormal.z * theNormal.z - 1.0)\n"
48   "        + aSHCoeffs[8] * (theNormal.x * theNormal.x - theNormal.y * theNormal.y);\n"
49   "}\n"
50   "#endif\n"
51   "\n"
52   "// front and back material properties accessors\n"
53   "#if defined(THE_IS_PBR)\n"
54   "uniform vec4 occPbrFrontMaterial[3];\n"
55   "uniform vec4 occPbrBackMaterial[3];\n"
56   "\n"
57   "#define MIN_ROUGHNESS 0.01\n"
58   "float occRoughness (in float theNormalizedRoughness) { return theNormalizedRoughness * (1.0 - MIN_ROUGHNESS) + MIN_ROUGHNESS; }\n"
59   "vec4  occPBRMaterial_Color(in bool theIsFront)     { return theIsFront ? occPbrFrontMaterial[0]     : occPbrBackMaterial[0]; }\n"
60   "vec3  occPBRMaterial_Emission(in bool theIsFront)  { return theIsFront ? occPbrFrontMaterial[1].rgb : occPbrBackMaterial[1].rgb; }\n"
61   "float occPBRMaterial_IOR(in bool theIsFront)       { return theIsFront ? occPbrFrontMaterial[1].w   : occPbrBackMaterial[1].w; }\n"
62   "float occPBRMaterial_Metallic(in bool theIsFront)  { return theIsFront ? occPbrFrontMaterial[2].b   : occPbrBackMaterial[2].b; }\n"
63   "float occPBRMaterial_NormalizedRoughness(in bool theIsFront) { return theIsFront ? occPbrFrontMaterial[2].g : occPbrBackMaterial[2].g; }\n"
64   "#else\n"
65   "uniform vec4 occFrontMaterial[5];\n"
66   "uniform vec4 occBackMaterial[5];\n"
67   "\n"
68   "vec4  occFrontMaterial_Ambient(void)      { return occFrontMaterial[0]; }\n"
69   "vec4  occFrontMaterial_Diffuse(void)      { return occFrontMaterial[1]; }\n"
70   "vec4  occFrontMaterial_Specular(void)     { return occFrontMaterial[2]; }\n"
71   "vec4  occFrontMaterial_Emission(void)     { return occFrontMaterial[3]; }\n"
72   "float occFrontMaterial_Shininess(void)    { return occFrontMaterial[4].x; }\n"
73   "float occFrontMaterial_Transparency(void) { return occFrontMaterial[4].y; }\n"
74   "\n"
75   "vec4  occBackMaterial_Ambient(void)       { return occBackMaterial[0]; }\n"
76   "vec4  occBackMaterial_Diffuse(void)       { return occBackMaterial[1]; }\n"
77   "vec4  occBackMaterial_Specular(void)      { return occBackMaterial[2]; }\n"
78   "vec4  occBackMaterial_Emission(void)      { return occBackMaterial[3]; }\n"
79   "float occBackMaterial_Shininess(void)     { return occBackMaterial[4].x; }\n"
80   "float occBackMaterial_Transparency(void)  { return occBackMaterial[4].y; }\n"
81   "#endif\n"
82   "\n"
83   "// 2D texture coordinates transformation\n"
84   "vec2  occTextureTrsf_Translation(void) { return occTexTrsf2d[0].xy; }\n"
85   "vec2  occTextureTrsf_Scale(void)       { return occTexTrsf2d[0].zw; }\n"
86   "float occTextureTrsf_RotationSin(void) { return occTexTrsf2d[1].x; }\n"
87   "float occTextureTrsf_RotationCos(void) { return occTexTrsf2d[1].y; }\n"
88   "//! @endfile DeclarationsImpl.glsl\n";