title: eye-space pixel width in GLSL vertex shader
body: <p>I want to compute the eye-space width of a pixel's projected pyramid at the current vertex location in a glsl vertex shader, but I can't seem to get the math right. Here is an obviously incorrect example:</p>
  
  <pre><code>// GLSL VERTEX SHADER
  #version 410 compatibility
  
  uniform vec4 viewport; // same as glViewport​
  in vec4 gl_Vertex;
  
  void main ()
  {
      gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
      float pixelWidth = gl_Position.z / viewport.z;
  &lt;snip&gt;
  </code></pre>
  
  <p>But this does not account for the FOV or clipping planes.</p>