Skip to content

Latest commit

 

History

History
56 lines (37 loc) · 4.4 KB

README.md

File metadata and controls

56 lines (37 loc) · 4.4 KB

The Ray Tracer Challenge... in .NET Core

This repo holds the code for a ray tracer following this book: The Ray Tracer Challenge - A Test-Driven Guide to Your First 3D Renderer.

I'm blogging my adventures implementing this ray tracer on my blog: codeclimber.net.nz.

Technologies used

The project will be implemented with .NET Core 2.2, with no external libraries, to adhere the most to the concept of the book, which is to build everything from scratch, even features that might exist already as part of .NET Standard or in other packages, like Color, Point, image rendering and serializing.

My objective is also to build everything using a Mac, the dotnet CLI and VS Code, to prove (mostly to myself) that this is a feasible approach, and that you can do everything you need without the full-blown Visual Studio.

I'll also try to use the latest features of the C# language, whenever makes sense.

The book recommends the usage of Cucumber for the testing, and even provides the full set of features in Gherkin. SpecFlow is the only Gherkin implementation for .NET, but seems like the support for .NET Core is not very advanced, and still relies on their Visual Studio plugin for generating the test files. So I'll start with plain old unit testing with xUnit, and will move to SpecFlow later.

What I'm trying to achieve

Nowadays I spend most of my time building CMS-based projects, using APIs provided by vendors, and aggregating results coming from Cloud-based services. So, mostly I want to re-discover the fun of developing something from scratch.

I also want to learn new things, improve the knowledge I have and, since there is a lot math involved, re-learn things I've learned at the university.

Specifically, things I hope to learn better are:

  • Obviously, how raytracing works;
  • Math, Algebra, Matrix, Vectors and similar stuff;
  • usage of the dotnet CLI;
  • a more advanced usa of VS Code (now I mostly use it "just" as text editor);
  • New features of C# (with new I mean from v6 onwards);
  • xUnit;
  • BDD with Gherkin and SpecFlow;
  • performance testing once everything is done.

Repository structure

This master branch contains the latest state of the ray tracer library and tests. Additionally, some chapters have some self-contained applications, so there will be some additional projects as well.

  • Exercises: Contains the implementation of the "Putting It Together" section at the end of each chapter.
    • Chapter1: Basic physics exercise of lauching a bullet at a given angle with gravity and wind.
  • src: Implementation of the raytracer library and the tests.
  • blog-posts: I'm documenting my learning process on my blog, and the posts are stored here.
  • resources : Collection of other material useful for the projects, like links I found useful, articles or anything else really.

Evolution of the library

To look at how the main library and test suite evolved through the book, each chapter has a branch, sometimes multiple when it makes sense. It starts with Chapter 0, which is the preparation of environment.

  • Chapter 0.1 - Just a script that uses the dotnet CLI to create the project structure and makes sure everything is working fine.
  • Chapter 0.2 - The basic projects (lib and xUnit test lib) with simple code to make sure testing works fine.
  • Chapter 1.1 - Implemented basic algebra of Tuples, Vectors and Points (Equality, Sum, Subtraction, Negative).
  • Chapter 1.2 - Implemented vector-specific operations, like Normalization, Magnitude, Dot and Cross Product.
  • Chapter 1 End - Refactored previous implementation and implemented working Exercise 1
  • Chapter 2.1 - Implemented Color class and its operations.
  • Chapter 2.2 - Implemented Canvas and serilization of images as PPM file
  • Chapter 2 End - Implemented Exercise 2