Writing a Ray Tracer in Swift
September 13, 2020
I recently purchased a book called The Ray Tracer Challenge, written by Jamis Buck. The book takes a test-driven approach to guide the reader through the process of implementing a ray tracer from scratch, explaining the mathematical processes and graphics algorithms involved along the way.
I had dabbled with ray tracing years ago, but didn’t have much time to devote to it and didn’t get very far past rendering spheres with basic shading. It’s been fun to pick it back up by reading this book, and being able to get further along thanks to having all of the necessary information explained and illustrated clearly in one place.
I’ve started writing a ray tracer in Swift, which can be found on GitHub. It utilizes SwiftUI to present images on screen. Thanks to live previews of SwiftUI content views in Xcode, there’s almost immediate feedback when modifying code to make changes to the rendered scene.
If you have an interest in ray tracing, or graphics programming in general, I highly recommend The Ray Tracer Challenge.