The Ray Tracer Challenge

This is my implementation of Jamis Buck's amazing book The Ray Tracer Challenge using C#.

Demo 🚀

Enjoy the demo here: TheRayTracerChallenge.

Goals:

Structure

The source code is in the src folder, and the demo, TheRayTracerChallenge, is in the docs folder as required by GitHub Pages.

Solution

The solution, as described above, is in the src folder, and it contains the following important items:

  • RayTracer project: It is the most important piece of code as it implements the data structures and algorithms described in the book. It is shared between the C# console applications and Blazor WebAssembly application.
  • RayTracer.Tests project: It implements all the unit tests described in the book.
  • RayTracer.Demos project: It implements, as a class library, all the demos of the solution. It makes use of the RayTracer project. It is shared between the C# console applications and Blazor WebAssembly application.
  • RayTracer.Demos.Tests projects: It implements some unit tests that make sure that some needed constraints are followed.
  • Demos folder: Contains several projects implementing the RayTracer.Demos demos as C# console applications. These demos make use of the RayTracer and RayTracer.Demos projects.
  • RayTracer.Demos.Browser: It is a C# console application used as a container to execute all the demos. It makes use of RayTracer and RayTracer.Demos projects.
  • RayTracer.Blazor Project: It is the Blazor WebAssembly implementation of the demos in RayTracer.Demos project. It makes use of RayTracer and RayTracer.Demos projects.
  • Mazes.Services Project: It implements some services and helper methods used by other projects.
  • Mazes.Services.Test: It is a C# console applications used as a container of all the demos. It allows us to select and execute any demo.

Final thoughts

It has been an awesome experience to share code between the C# the console applications and the Blazor WebAssembly application, making it very straightforward to convert to a web application the implementation of the book with very little effort.

Please, feel free to send issues or pull requests. Any feedback is always welcome!

Examples

01-Projectile 02-Clock 03-Spheres 04-Spheres3D
05-Scenes 06-Shadows 07-Planes 08-Patterns
09-Reflections 10-Refractions 11-Fresnel 12-Cubes
13-Cylinders 14-Cones 15-Groups 16-Triangles
17-CSG 18-Cover TestResults Web