Z-buffer algorithm
After transformations the visibility order can be determined by comparing Z coordinates at each pixel. Z coordinate in NDC increases with the increase in the distance to the camera.
Initialize all pixels to a large positive value.
For each pixel (i,j) obtained by scan converting the polygon
Find Z value for the pixel (i,j)
if Z < Zold already recorded for the pixel (i,j)
replace the color value by the color of the curent polygon and Zold with Z