title: Attenuation does not get applied correctly
body: <p>I can't understand does the light attenuation correctly get applied or not.</p>
  
  <p><a href="https://i.stack.imgur.com/B7i3A.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B7i3A.png" alt="enter image description here"></a></p>
  
  <p>It seems like it's not because the shininess of the steel frame for cube located at <code>(-500, 100, 100)</code>(at the left) is too much highlighted - must be less I think, considering that the light position (white cube) is <code>(100.0, 100.0f, 100.0f)</code>.</p>
  
  <p>I'm using this formula to get the attenuation</p>
  
  <pre><code>1.0 / (constant + linear * distance + quadratic * (distance^2))
  </code></pre>
  
  <p>Fragment shader:</p>
  
  <pre><code>#version 450 core
  
  struct Material {
      sampler2D diffuse;
      sampler2D specular;
      float shininess;
  };
  
  struct Light {
      vec3 position;
      vec3 ambient;
      vec3 diffuse;
      vec3 specular;    
      float constant;
      float linear;
      float quadratic;
  };
  
  uniform vec3 cameraPosition;
  uniform Material material;
  uniform Light light;    
  in vec3 vNormal;
  in vec2 vTexCoord;
  in vec4 fragPosition;
  out vec4 color;
  
  void main() {
      vec3 norm = vNormal;
      vec3 lightDir = normalize(light.position - vec3(fragPosition.xyz));
      vec3 viewDir = normalize(cameraPosition - vec3(fragPosition.xyz));
      vec3 reflectDir = reflect(-lightDir, norm);
  
      vec3 ambient  = light.ambient * vec3(texture(material.diffuse, vTexCoord));
      vec3 diffuse  = light.diffuse * max(dot(norm, lightDir), 0.0) * vec3(texture(material.diffuse, vTexCoord));
      vec3 specular = light.specular * pow(max(dot(viewDir, reflectDir), 0.0f), material.shininess) * vec3(texture(material.specular, vTexCoord));
  
      float d = length(lightDir);
      float attenuation = 1.0f / (light.constant + light.linear * d + light.quadratic * (d * d));
  
  
      ambient *= attenuation;
      diffuse *= attenuation;
      specular *= attenuation;
  
      color = vec4(ambient + diffuse + specular, 1.0f);
  }
  </code></pre>
  
  <p>And passing the following values to the program</p>
  
  <pre><code>glUniform1f(lightConstantLoc,  1.0);
  glUniform1f(lightLinearLoc,    0.1);
  glUniform1f(lightQuadraticLoc, 0.01);
  </code></pre>
  
  <p>Also same positions but changed the view angle</p>
  
  <p><a href="https://i.stack.imgur.com/oyEwj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oyEwj.png" alt="enter image description here"></a>
  So what's wrong there? Are my calculations wrong? What's going there?</p>