1 // This file has been automatically generated from resource file src/Shaders/PhongPointLight.glsl
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 (view space)\n"
10 "//! @param theIsFront front/back face flag\n"
11 "void occPointLight (in int theId,\n"
12 " in vec3 theNormal,\n"
14 " in vec3 thePoint,\n"
15 " in bool theIsFront)\n"
17 " vec3 aLight = vec3 (occWorldViewMatrix * vec4 (occLight_Position (theId), 1.0)) - thePoint;\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"
25 " vec3 aHalf = normalize (aLight + theView);\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"
31 " float aSpecl = 0.0;\n"
32 " if (aNdotL > 0.0)\n"
34 " aSpecl = pow (aNdotH, occMaterial_Shininess (theIsFront));\n"
37 " Diffuse += occLight_Diffuse (theId) * aNdotL * anAtten;\n"
38 " Specular += occLight_Specular(theId) * aSpecl * anAtten;\n"