title: Specular highlights depend on camera distance
body: <p>I just tried implementing specular highlights. The issue is that when moving far away from the surface, the highlight becomes stronger and stronger and the edge of the highlight becomes very harsh. When moving too near to the surface, the highlight completely disappears.</p>
  
  <p>This is the related part of my fragment shader. All computations are in view space. I use a directional sun light.</p>
  
  <pre><code>// samplers
  vec3  normal    = texture2D(normals,   coord).xyz;
  vec3  position  = texture2D(positions, coord).xyz;
  float shininess = texture2D(speculars, coord).x;
  
  // normalize directional light source
  vec3 source;
  if(directional) source = position + normalize(light);
  else source = light;
  
  // reflection
  float specular = 0;
  vec3 lookat = vec3(0, 0, 1);
  float reflection = max(0, dot(reflect(position, normal), lookat));
  int power = 5;
  specular = shininess * pow(reflection, power);
  
  // ...
  
  // output
  image = color * attenuation * intensity * (fraction + specular);
  </code></pre>
  
  <p>This is a screenshot of my lighting buffer. You can see that the foremost barrel has no specular highlight at all while the ones far away shine much too strong. The barrel in the middle is lighted as desired. </p>
  
  <p><img src="https://i.stack.imgur.com/gWRvP.png" alt="far highlights are too strong and near highlights disappear"></p>
  
  <p>What am I doing wrong?</p>