<blockquote>
  <p>I know that in a typical GLSL shader you need to apply the modelview matrix to the vertices, so that you obtain a vertex in eye coordinates.</p>
</blockquote>

<p>This is not quite correct, you need to apply the modelview<em>projection</em> matrix and thus transform your vertices into Clip Space Coordinates. 
You can apply the ModelView Matrix in certain instances, e.g. if you want to calculate light in Eye Space. However, the <code>gl_Position</code> will then still not use the ModelView but the ModelViewProjection Matrix and your light/whatever- position will use the ModelView Matrix and be transferred to the fragment shader via the <code>out</code> variables.</p>

<p>For a more detailed discussion, you can look into <a href="https://stackoverflow.com/questions/49259363/how-to-get-screen-widget-coordinates-from-world-coordinates/49260694#49260694">the comments on this question</a>, I had to be corrected about that myself (since not all literature is clear/correct about Normalized Device Space and Clip Space).</p>

CC BY-SA 3.0
2018-04-26T14:23:31.700Z
2018-04-26T14:23:31.700Z
Tare
<p>I've found a site that provides an overview of the OpenGL pipeline: </p>

<p><a href="https://www.khronos.org/opengl/wiki/Rendering_Pipeline_Overview" rel="nofollow noreferrer">Rendering pipeline overview</a></p>

<p>Now in the 3th phase (vertex processing) it says that after the transform feedback, there is the primitive clipping. If I am not mistaken, the primitive clipping must occur after that the vertices are multiplied by the projection matrix, otherwise it's impossible to determine if the primitives are inside or outside the view volume defined with <em>glFrustum()</em>.</p>

<p>I know that in a typical GLSL shader you need to apply the modelview matrix to the vertices, so that you obtain a vertex in eye coordinates. So if I am not mistaken, at the end of the vertex shader you don't have vertices defined in clip coordinates yet. But this makes me think: where is the projection matrix applied? it seems like it's missing in this pipeline overview. </p>

CC BY-SA 3.0
2018-04-26T16:34:56.687Z
"*otherwise it's impossible to determine if the primitives are inside or outside the view volume defined with glFrustum()*" That page defines the core profile of OpenGL; `glFrustum` *does not exist* in modern OpenGL anymore. Projection is the responsibility of the writer of the shader, not of the rendering pipeline.
Nicol Bolas
<opengl>
At which stage of the pipeline is the projection transform applied?
Ramy Al Zuhouri
# At which stage of the pipeline is the projection transform applied?

(Asked by: username_0 on 2018-04-26)

I've found a site that provides an overview of the OpenGL pipeline:

[Rendering pipeline overview](https://www.khronos.org/opengl/wiki/Rendering_Pipeline_Overview)

Now in the 3th phase (vertex processing) it says that after the transform feedback, there is the primitive clipping. If I am not mistaken, the primitive clipping must occur after that the vertices are multiplied by the projection matrix, otherwise it's impossible to determine if the primitives are inside or outside the view volume defined with *glFrustum()*.

I know that in a typical GLSL shader you need to apply the modelview matrix to the vertices, so that you obtain a vertex in eye coordinates. So if I am not mistaken, at the end of the vertex shader you don't have vertices defined in clip coordinates yet. But this makes me think: where is the projection matrix applied? it seems like it's missing in this pipeline overview.

**Tags:** opengl

> **Comments:**
> **username_1**: "*otherwise it's impossible to determine if the primitives are inside or outside the view volume defined with glFrustum()*" That page defines the core profile of OpenGL; `glFrustum` *does not exist* in modern OpenGL anymore. Projection is the responsibility of the writer of the shader, not of the rendering pipeline.  

---

## 1 answers

### Answer by username_2 on 2018-04-26. Score: 2 | Accepted answer

> I know that in a typical GLSL shader you need to apply the modelview matrix to the vertices, so that you obtain a vertex in eye coordinates.

This is not quite correct, you need to apply the modelview*projection* matrix and thus transform your vertices into Clip Space Coordinates.
You can apply the ModelView Matrix in certain instances, e.g. if you want to calculate light in Eye Space. However, the `gl_Position` will then still not use the ModelView but the ModelViewProjection Matrix and your light/whatever- position will use the ModelView Matrix and be transferred to the fragment shader via the `out` variables.

For a more detailed discussion, you can look into [the comments on this question](https://stackoverflow.com/questions/49259363/how-to-get-screen-widget-coordinates-from-world-coordinates/49260694#49260694), I had to be corrected about that myself (since not all literature is clear/correct about Normalized Device Space and Clip Space).


---

