1 // Based on Point Light shader from oZone3D.Net
\r
2 // http://www.ozone3d.net/tutorials/glsl_lighting_phong_p2.php
\r
4 varying vec3 normal, light_direction, eye_position;
\r
5 varying float attenuation;
\r
9 normal = gl_NormalMatrix * gl_Normal;
\r
11 vec3 vVertex = vec3(gl_ModelViewMatrix * gl_Vertex);
\r
12 light_direction = vec3(gl_LightSource[0].position.xyz - vVertex);
\r
13 eye_position = -vVertex;
\r
15 float d = length(light_direction);
\r
17 attenuation = 1.0 / ( gl_LightSource[0].constantAttenuation +
\r
18 (gl_LightSource[0].linearAttenuation*d) +
\r
19 (gl_LightSource[0].quadraticAttenuation*d*d) );
\r
21 gl_Position = ftransform();
\r