1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
void directionalLightFront( in int i, in vec3 normal )
{
float nDotVP; // normal . light direction
float nDotHV; // normal . light half vector
float pf; // power factor
vec3 vLight = normalize(tsLightVector[i]);
vec3 vView = normalize(tsViewVector);
vec3 halfVector = normalize(vLight + vView);
nDotHV = max( 0.0, dot(normal, halfVector) );
nDotVP = max(0.0, dot(normal, vLight));
if ( nDotVP == 0.0 || nDotHV == 0.0 )
{
pf = 0.0;
}
else
{
pf = pow( nDotHV, gl_FrontMaterial.shininess);
accumSpecular += gl_LightSource[i].specular * pf ;
}
accumAmbient += gl_LightSource[i].ambient;
accumDiffuse += gl_LightSource[i].diffuse * nDotVP;
} |
Partager