TRTC – The Ray Tracer Challenge

VartsiaSwift, TRTC

The Ray Tracer Challenge by Jamis Buck - book cover

In my TRTC blog series I’m trying to follow the book ” The Ray Tracer Challenge ” written by Jamis Buck. I mean trying because while I’m writing this I’m not sure how the journey will end or if I will get lost somewhere on the way 😬.

The book gives you all the steps you need to take to build a 3D Renderer. Steps are given using a test-driven approach. First comes the test and then the implementation. The code that comes with the book is pseudo-code so the decision of how to implement those givens steps is left to reader. This is a book I have needed for a long time.

The tech stuff

I choose to use macOS as my programming platform. All the code will be written using either Swiftor MSL (Metal Shading Language). MSL is needed for shaders since I will use Metal as my graphics framework.

Test-driven development

The test-driven development is something I was not a familiar with. But I found a verry good video-course from the LinkedIn LEARNING site called Automated Testing in Xcode. It covers everything I needed to get started with the first challenges in the book.

Cocoa Framework

The codebase is organised so that there is Xcode workspace containing two Xcode projects. First is the actual Cocoa application project called the RayGIS. The other project is a Cocoa Framework project called the RGCore. Basically the RGCore will do the math and RayGIS displays the results. I found it also easier to do things this way to setup the Xcode to handle the test-driven development.

Source code

Finnish nick name for source code is “sorsa”. Sorsa in Finnish means duck. 🙂

There will be an indepented project folder for each Chapter of the book. So for example a folder for Chapter 3 will contain all code from the previous Chapters 1 and 2 too. Just open the Xcode workspace in the Chapter 3 folder and you are ready to go.

25.3.2019 Apple launched the new Xcode 10.2 and Swift 5. So the projects will be upgraded to use these new technologies.

All the source code will be published in gitlab.com as I get the material done (Chapter 1 is ready at the moment) and after I have decided what licence to use… if any at all.