code following along with Physically Based Rendering Techniques book