1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00
occt/src/Shaders/Shaders_PhongPointLight_glsl.pxx
kgv b470ebea04 0032200: Visualization, TKOpenGl - unify Phong/PBR light space calculations
Graphic3d_ShaderManager - Phong shading now uses World space calculations.
OpenGl_ShaderManager::pushLightSourceState() - fixed unnormalized direction of headlight source.
2021-03-17 19:53:13 +03:00

40 lines
1.6 KiB
Plaintext

// This file has been automatically generated from resource file src/Shaders/PhongPointLight.glsl
static const char Shaders_PhongPointLight_glsl[] =
"//! Function computes contribution of isotropic point light source\n"
"//! into global variables Diffuse and Specular (Phong shading).\n"
"//! @param theId light source index\n"
"//! @param theNormal surface normal\n"
"//! @param theView view direction\n"
"//! @param thePoint 3D position (world space)\n"
"//! @param theIsFront front/back face flag\n"
"void occPointLight (in int theId,\n"
" in vec3 theNormal,\n"
" in vec3 theView,\n"
" in vec3 thePoint,\n"
" in bool theIsFront)\n"
"{\n"
" vec3 aLight = occLight_Position (theId) - thePoint;\n"
"\n"
" float aDist = length (aLight);\n"
" float aRange = occLight_Range (theId);\n"
" float anAtten = occPointLightAttenuation (aDist, aRange, occLight_LinearAttenuation (theId), occLight_ConstAttenuation (theId));\n"
" if (anAtten <= 0.0) return;\n"
" aLight /= aDist;\n"
"\n"
" vec3 aHalf = normalize (aLight + theView);\n"
"\n"
" vec3 aFaceSideNormal = theIsFront ? theNormal : -theNormal;\n"
" float aNdotL = max (0.0, dot (aFaceSideNormal, aLight));\n"
" float aNdotH = max (0.0, dot (aFaceSideNormal, aHalf ));\n"
"\n"
" float aSpecl = 0.0;\n"
" if (aNdotL > 0.0)\n"
" {\n"
" aSpecl = pow (aNdotH, occMaterial_Shininess (theIsFront));\n"
" }\n"
"\n"
" Diffuse += occLight_Diffuse (theId) * aNdotL * anAtten;\n"
" Specular += occLight_Specular(theId) * aSpecl * anAtten;\n"
"}\n";