Move shadow code in renderer.rs into a function.