0032200: Visualization, TKOpenGl - unify Phong/PBR light space calculations
[occt.git] / src / Shaders / Shaders_PhongPointLight_glsl.pxx
1 // This file has been automatically generated from resource file src/Shaders/PhongPointLight.glsl
2
3 static const char Shaders_PhongPointLight_glsl[] =
4   "//! Function computes contribution of isotropic point light source\n"
5   "//! into global variables Diffuse and Specular (Phong shading).\n"
6   "//! @param theId      light source index\n"
7   "//! @param theNormal  surface normal\n"
8   "//! @param theView    view direction\n"
9   "//! @param thePoint   3D position (world space)\n"
10   "//! @param theIsFront front/back face flag\n"
11   "void occPointLight (in int  theId,\n"
12   "                    in vec3 theNormal,\n"
13   "                    in vec3 theView,\n"
14   "                    in vec3 thePoint,\n"
15   "                    in bool theIsFront)\n"
16   "{\n"
17   "  vec3 aLight = occLight_Position (theId) - thePoint;\n"
18   "\n"
19   "  float aDist = length (aLight);\n"
20   "  float aRange = occLight_Range (theId);\n"
21   "  float anAtten = occPointLightAttenuation (aDist, aRange, occLight_LinearAttenuation (theId), occLight_ConstAttenuation (theId));\n"
22   "  if (anAtten <= 0.0) return;\n"
23   "  aLight /= aDist;\n"
24   "\n"
25   "  vec3 aHalf = normalize (aLight + theView);\n"
26   "\n"
27   "  vec3  aFaceSideNormal = theIsFront ? theNormal : -theNormal;\n"
28   "  float aNdotL = max (0.0, dot (aFaceSideNormal, aLight));\n"
29   "  float aNdotH = max (0.0, dot (aFaceSideNormal, aHalf ));\n"
30   "\n"
31   "  float aSpecl = 0.0;\n"
32   "  if (aNdotL > 0.0)\n"
33   "  {\n"
34   "    aSpecl = pow (aNdotH, occMaterial_Shininess (theIsFront));\n"
35   "  }\n"
36   "\n"
37   "  Diffuse  += occLight_Diffuse (theId) * aNdotL * anAtten;\n"
38   "  Specular += occLight_Specular(theId) * aSpecl * anAtten;\n"
39   "}\n";