front/behind detection for proper image rendering