It is called depth testing. There is a depth buffer (or z buffer) which contains the depth value for each pixel. When a pixel is to be written, its depth is calculated and compared the value in depth buffer, if it is closer to camera then it is drawn and value of depth buffer is changed, else the pixel is ignored.
It is called depth testing. There is a depth buffer (or z buffer) which contains the depth value for each pixel. When a pixel is to be written, its depth is calculated and compared the value in depth buffer, if it is closer to camera then it is drawn and value of depth buffer is changed, else the pixel is ignored.