refactoring and depth prepass skeleton