Thats easy, the function that converts the vector from the world to the screen has the depth in the z value.