Transforming a Coordinate from the Shader to the Screen
We are now familiar with normalized device coordinates, and we know that in order for a vertex to display on the screen, its x, y, and z components all need to be in the range of [-1, 1]. Let’s take a look at the following flow chart to review how a coordinate gets transformed from the original gl_Position written by the vertex shader to the final coordinate onscreen:
There are two transformation steps and three different coordinate spaces.
When the vertex shader writes a value out to gl_Position, OpenGL expects this position to be in clip space. The logic behind clip space is very ...