This repository documents my ongoing study of ray tracing principles, drawing knowledge from raytracing.github.io. Although the site provides code examples, I've opted to heavily refactor and customize my implementations for learning purposes and to, at times, improve on the code's quality. Notable changes include:
- More consistent organising of code into classes
- Utilising modern C++ (C++14 and up)
Final Result
(In reverse-chronological order)
- Add a field of view to camera
- Enable rotation functionality for camera
- Add dielectric material
- Add reflectance
- Add abstract class for materials
- Add metal and lambertian materials
- Add fuzz factor for metal reflection rays
- Remove 'shadow acne'
- Alter to use true Lambertian reflection
- Add gamma correction, giving a more accurate color intensity
- Add
Countdownto track progress ofrender() - Implement a simple diffuse material
- Colour sphere according to its normal vectors
- Create abstract class
HittableEntityand classListOfHittables - Add
Intervalclass and some misc. utility functions - Add antialiasing
- Create Sphere class
- Detect if ray hits sphere. If so,
ray_colour()returns black
- Add a
CameraandViewportclass - Flesh out rendering logic, rendering an image (see above) based on the y-direction of the rays
- Make Python script to view PPM images and integrated it into my C++ code
- Start creating some of the core classes and functions: Vec3, Ray,
render(), etc. - Render first image (with some temporary function bodies) to test that the whole process from file creation, writing to the file, to loading/viewing it with the Python script ran correctly
This project uses fmt and Microsoft's gsl libraries. You can download them with:
brew install fmt
brew install cpp-gsl
To build and run, follow these steps:
- Clone or download this repository to your local machine.
- Make sure you have the required dependencies installed:
fmtand Microsoft'sgsllibraries. - Open your terminal and navigate to the project directory.
- Compile the source code using your preferred C++20 compiler, ensuring that the required dependencies are linked
- Run the program.










