"Physically Based Rendering" walks you through the theory behind, and the implementation of, a photo-realistic rendering system (not real-time).
An extremely thorough guide to ray tracing.
https://www.amazon.com/Physically-Based-Rendering-Third-Impl...