- if (gl_LightSource[i].position.w != 0.0)
- {
- // positional light source
- lightDir = (gl_LightSource[i].position.xyz - position);
- float dist = length(lightDir);
- lightDir = normalize(lightDir);
- attenFactor = 1.0/( gl_LightSource[i].constantAttenuation +
- gl_LightSource[i].linearAttenuation * dist +
- gl_LightSource[i].quadraticAttenuation * dist * dist );
- }
- else
- {
- // directional light source
- attenFactor = 1.0;
- lightDir = gl_LightSource[i].position.xyz;
- }