1 2float DirSpotLight(in vec3 dir, 3 in vec3 light_position, 4 in vec3 eye, 5 in vec3 ecPosition3, 6 in vec3 normal, 7 inout vec4 diffuse, 8 inout vec4 specular) 9{ 10 float nDotVP; 11 float nDotHV; 12 float pf; 13 vec3 hv = normalize(eye + dir); 14 nDotVP = max(0.0, dot(normal, dir)); 15 nDotHV = max(0.0, dot(normal, hv)); 16 float shininess = gl_FrontMaterial.shininess; 17 if (nDotVP == 0.0) 18 pf = 0.0; 19 else 20 pf = pow(nDotHV, shininess); 21 22 diffuse *= nDotVP; 23 specular *= pf; 24 return length(light_position - ecPosition3); 25} 26