Is this the correct way of calculating and applying attenuation?

This is my basic diffuse shader with attenuation:

*.vert*

varying vec3 vertex_light_position; varying vec3 vertex_light_half_vector; varying vec4 color; varying vec3 N; varying vec3 v; void main(void) { v = vec3(gl_ModelViewMatrix * gl_Vertex); N = normalize(gl_NormalMatrix * gl_Normal); color = gl_Color; vertex_light_position = normalize(gl_LightSource[0].position.xyz); vertex_light_half_vector = normalize(gl_LightSource[0].halfVector.xyz); gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; }

*.frag*

varying vec3 vertex_light_position; varying vec3 vertex_light_half_vector; varying vec4 color; varying vec3 N; varying vec3 v; void main() { float constantAttenuation=1.0; float linearAttenuation=1.0; float quadraticAttenuation=0.02; float dist = length(gl_LightSource[0].position - v); float att = 1.0/(constantAttenuation + (linearAttenuation * dist) + (quadraticAttenuation * dist * dist)); vec3 L = normalize(gl_LightSource[0].position.xyz - v); vec3 E = normalize(-v); vec3 R = normalize(reflect(-L,N)); vec4 diffuse_color = vec4(0.0,1.0,0.0,0.0); float diffuse_value = max(dot(N,L), 0.0); if (gl_FrontFacing){ gl_FragColor = color + (((diffuse_color-color) * (diffuse_value))*att); }else{ gl_FragColor = color; } }