title: How to transform directional light to camera space in GLSL
body: <p>I have the following GLSL code for lighting:</p>
  
  <pre><code>uniform vec3 lightDir; // Parallel light
  uniform float ambient;
  uniform vec3 lightColour;
  
  void main()
  {
       gl_Position = ftransform();
  
       vec3 eyeNormal = normalize(gl_NormalMatrix * gl_Normal);
       float intensity = max(ambient, dot(eyeNormal, normalize(-lightDir));
  
       gl_FrontColor = gl_Color * vec4(lightColour, 1.0) * intensity;
  }
  </code></pre>
  
  <p>The light vector is specified in world space.  I set the camera orientation and position using <code>gluLookAt</code>.  Since OpenGL assumes the light vector is in camera space, the light moves with the camera instead of staying in a fixed orientation.</p>
  
  <p>I tried activating the shader and setting the light vector both before and after I call <code>gluLookAt</code>, but I get the same effect.  What exactly do I have to do to properly transform the light vector?</p>