title: Trouble with GLSL dot product
body: <p>So I was trying to implement basic diffuse lighting using OpenGL. I wrote a simple shader that would take a normal vector and a light vector and calculate the brightness of a pixel using the dot product of said vectors. Here are my outputs:</p>
  <ul>
  <li>Light coming from the left ([1, 0, 0] as light vector)
  <a href="https://i.stack.imgur.com/fGusU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fGusU.png" alt="1 0 0" /></a></li>
  <li>Light coming down ([0, -1, 0] as light vector)
  <a href="https://i.stack.imgur.com/gI4oE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gI4oE.png" alt="0 -1 0" /></a></li>
  <li>Light coming from behind ([0, 0, 1] as light vector)
  <a href="https://i.stack.imgur.com/IbEeP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IbEeP.png" alt="0 0 1" /></a></li>
  </ul>
  <p>As you can see, it works just fine for the first two cases, but it completely breaks for the third. By the way, [0, 0, -1] doesn't work either and [0, 1, 1] gives the same output as if the light was coming up ([0, 1, 0]). Here are my shaders :</p>
  <ul>
  <li>Vertex shader:</li>
  </ul>
  <pre><code>#version 330 core
  
  layout (location = 0) in vec3 aPos;
  layout (location = 1) in vec3 aNormal;
  
  uniform mat4 model;
  uniform mat4 view;
  uniform mat4 projection;
  
  uniform vec3 lightDirection;
  
  out vec3 normal;
  out vec3 lightDir;
  
  void main()
  {
      normal = normalize(aNormal);
      lightDir = normalize(lightDirection);
  
      gl_Position = projection * view * model * vec4(aPos, 1.0f);
  }
  </code></pre>
  <ul>
  <li>Fragment shader:</li>
  </ul>
  <pre><code>#version 330 core
  
  in vec3 normal;
  in vec3 lightDir;
  
  out vec4 FragColor;
  
  void main()
  {
      float grey = max(dot(-lightDir, normal), 0.0f);
      FragColor = vec4(grey, grey, grey, 1.0f);
  }
  </code></pre>
  <p>I assume the issue has something to do with the dot product, but I can't find why.</p>