refactored code and combined indirect and direct illumination