title: Glsl phong shader and camera
body: <p>I know this question was asked a lot already, but I still can't manage to do it right.</p>
  
  <p>So, in my vertex shader I need to get light postition and eye position. Here is my code:</p>
  
  <pre><code>void main(void)
  {
      vec3    p = vec3      ( gl_ModelViewMatrix * gl_Vertex );
  
      l = normalize (vec3 (gl_LightSource[0].position));
      v = normalize ( vec3 ( eyePos )  - p );
      n = normalize ( gl_NormalMatrix * gl_Normal );
  
      gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
  }
  </code></pre>
  
  <p>As the result light moves with the movement of camera. What exactly do I need to do here? Possibly without use of non-opengl matrices.</p>
  
  <p>Is there an example of glsl lighting with proper camera control?</p>
  
  <p><strong>* UPDATE *</strong></p>
  
  <p>Thanks to Kos, i managed "lights move with camera" problem, but here is another one:</p>
  
  <p>I have</p>
  
  <pre><code>glLightfv(GL_LIGHT0, GL_POSITION, light_position);
  glEnable(GL_LIGHT0);
  ctLight -&gt; enable();
  
  glPushMatrix();
      glTranslatef(0, 0, 0);
      glRotatef(angle, 0, 1, 0);
      glutSolidTeapot(2.0);
  glPopMatrix();
  
  glPushMatrix();
      glTranslatef(0, 0, 8);
      glRotatef(angle, 0, 1, 0);
      glutSolidTeapot(2.0);
  glPopMatrix();
  
  ctLight -&gt; disable();
  glDisable(GL_LIGHT0);
  </code></pre>
  
  <p>Now the second teapot lights the same as one in (0, 0, 0). How do i fix this?</p>
  
  <p>Vertex shader code in case:</p>
  
  <pre><code>void main(void)
  {
      vec3    p = vec3 ( gl_ModelViewMatrix * gl_Vertex );            // transformed point to world space
  
      l = normalize ( vec3 (gl_LightSource[0].position) );
      v = normalize ( - p );  
  
      h = normalize ( l + v );
      n = normalize ( gl_NormalMatrix * gl_Normal );                  // transformed n
  
      gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
  }
  </code></pre>