The objective of this step is to find a transformation matrix to transform points expressed in normalized device coordinates to screen coordinates.
The canonical view volume needs to be mapped to the screen that has pixels in a way so that points with and are mapped to the left and right sides of the screen, respectively, and and are mapped to the bottom and top sides of the screen, respectively. The -coordinate isn’t visible in a 2D image, so it can be discarded for the mapping.
Since the mapping is linear, we can use the
linear interpolation method
:
Given:
The value of is:
The value of is found in a similar way:
Finally, the transformation matrix that converts points from NDC to screen coordinates is:
Note that the -coordinate doesn’t need to be modified since it doesn’t affect the projection in the image. The -coordinate is still used to check the order in which objects should be drawn.