0032083: Visualization, TKOpenGl - PBR rendering is unavailable on Apple A12 Bionic...
[occt.git] / src / Shaders / Shaders_DirectionalLightShadow_glsl.pxx
1 // This file has been automatically generated from resource file src/Shaders/DirectionalLightShadow.glsl
2
3 static const char Shaders_DirectionalLightShadow_glsl[] =
4   "#if (__VERSION__ >= 120)\n"
5   "//! Coefficients for gathering close samples for antialiasing.\n"
6   "//! Use only with decent OpenGL (array constants cannot be initialized with GLSL 1.1 / GLSL ES 1.1)\n"
7   "const vec2 occPoissonDisk16[16] = vec2[](\n"
8   " vec2(-0.94201624,-0.39906216), vec2( 0.94558609,-0.76890725), vec2(-0.09418410,-0.92938870), vec2( 0.34495938, 0.29387760),\n"
9   " vec2(-0.91588581, 0.45771432), vec2(-0.81544232,-0.87912464), vec2(-0.38277543, 0.27676845), vec2( 0.97484398, 0.75648379),\n"
10   " vec2( 0.44323325,-0.97511554), vec2( 0.53742981,-0.47373420), vec2(-0.26496911,-0.41893023), vec2( 0.79197514, 0.19090188),\n"
11   " vec2(-0.24188840, 0.99706507), vec2(-0.81409955, 0.91437590), vec2( 0.19984126, 0.78641367), vec2( 0.14383161,-0.14100790)\n"
12   ");\n"
13   "#endif\n"
14   "\n"
15   "//! Function computes directional light shadow attenuation (1.0 means no shadow).\n"
16   "float occDirectionalLightShadow (in sampler2D theShadow,\n"
17   "                                 in int  theId,\n"
18   "                                 in vec3 theNormal)\n"
19   "{\n"
20   "  vec4 aPosLightSpace = PosLightSpace[occLight_Index(theId)];\n"
21   "  vec3 aLightDir = vec3 (occWorldViewMatrix * vec4 (occLight_Position (theId), 0.0));\n"
22   "  vec3 aProjCoords = (aPosLightSpace.xyz / aPosLightSpace.w) * 0.5 + vec3 (0.5);\n"
23   "  float aCurrentDepth = aProjCoords.z;\n"
24   "  if (aProjCoords.x < 0.0 || aProjCoords.x > 1.0\n"
25   "   || aProjCoords.y < 0.0 || aProjCoords.y > 1.0\n"
26   "   || aCurrentDepth > 1.0)\n"
27   "  {\n"
28   "    return 1.0;\n"
29   "  }\n"
30   "\n"
31   "  vec2 aTexelSize = vec2 (occShadowMapSizeBias.x);\n"
32   "  float aBias = max (occShadowMapSizeBias.y * (1.0 - dot (theNormal, aLightDir)), occShadowMapSizeBias.y * 0.1);\n"
33   "#if (__VERSION__ >= 120)\n"
34   "  float aShadow = 0.0;\n"
35   "  for (int aPosIter = 0; aPosIter < 16; ++aPosIter)\n"
36   "  {\n"
37   "    float aClosestDepth = occTexture2D (theShadow, aProjCoords.xy + occPoissonDisk16[aPosIter] * aTexelSize).r;\n"
38   "    aShadow += (aCurrentDepth - aBias) > aClosestDepth ? 1.0 : 0.0;\n"
39   "  }\n"
40   "  return 1.0 - aShadow / 16.0;\n"
41   "#else\n"
42   "  float aClosestDepth = occTexture2D (theShadow, aProjCoords.xy).r;\n"
43   "  float aShadow = (aCurrentDepth - aBias) > aClosestDepth ? 1.0 : 0.0;\n"
44   "  return 1.0 - aShadow;\n"
45   "#endif\n"
46   "}\n";