title: GLSL light/highlight moving with camera
body: <p><strong>VC++ 2010, OpenGL, GLSL, SDL</strong></p>
  
  <p>I am moving over to shaders, and have run into a problem that originally occured while working with the ogl pipeline. That is, the position of the light seems to point in whatever direction my camera faces. In the ogl pipeline it was just the specular highlight, which was fixable with: </p>
  
  <pre><code>glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, 1.0f);
  </code></pre>
  
  <p>Here are the two shaders:</p>
  
  <p><strong>Vertex</strong></p>
  
  <pre><code>varying vec3 lightDir,normal;
  
  void main()
  {
      normal = normalize(gl_NormalMatrix * gl_Normal);
      lightDir = normalize(vec3(gl_LightSource[0].position));
  
      gl_TexCoord[0] = gl_MultiTexCoord0;
      gl_Position = ftransform();
  }
  </code></pre>
  
  <p><strong>Fragment</strong></p>
  
  <pre><code>varying vec3 lightDir,normal;
  uniform sampler2D tex;
  
  void main()
  {
      vec3 ct,cf;
      vec4 texel;
      float intensity,at,af;
  
      intensity = max(dot(lightDir,normalize(normal)),0.0);
  
      cf = intensity * (gl_FrontMaterial.diffuse).rgb + 
                          gl_FrontMaterial.ambient.rgb;
      af = gl_FrontMaterial.diffuse.a;
  
      texel = texture2D(tex,gl_TexCoord[0].st);
      ct = texel.rgb;
      at = texel.a;
  
      gl_FragColor = vec4(ct * cf, at * af);  
  }
  </code></pre>
  
  <p>Any help would be much appreciated!</p>