The objective of this step is to find a transformation matrix to transform points expressed in normalized device coordinates to screen coordinates

vscreen=Mvpvndc

The canonical view volume needs to be mapped to the screen that has nx×ny pixels in a way so that points with x=1,x=1 are mapped to the left and right sides of the screen respectively and y=1,y=1 are mapped to the bottom and top sides of the screen respectively, the z 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

f(x)=outlo+(outhioutlo)xinloinhiinlo

Given

  • outlo=0.5
  • outhi=nx0.5
  • inlo=1
  • inhi=1

The value of xscreen is

xscreen=0.5+nxxndc+12=12+nx2xndc+nx2=nx2xndc+nx12

The value of yscreen is found in a similar way

yscreen=ny2yndc+ny12

Finally the transformation matrix that converts points from NDC to screen coordinates is

Mvp=[nx200nx120ny20ny1200100001]

Note that the z-coordinate doesn’t need to be modified since it doesn’t affect the projection in the image, the z-coordinate is still used to check the order in which objects should be drawn