Tidy up renderDepthTexture into smaller functions