Ray-casting

A Cornell Box with two mirrored spheres

For this post I wanted to highlight my adventures into raytracing. There is nothing ground-breaking here, and it seems like a right of passage for all programmer (graphics and not) to create a ray-based rendering algorithm at some point or another.

This ray caster was completely hand made, all the way down to the matrix multiplications. all in C++. It only runs on CPU, but one of many extensions in the future could be to put it on GPU to get quicker convergence, and generally make waiting for renders far less painful.

I also implemented the obj parser that was used to parse the Cornell Box obj, and it’s mtl file. The experience was a fun one, and once some fun initial bug (see image below), it worked like a charm!

Some of the errors were quite pretty!

During the course of the project I mainly worked everything else out myself from what I’d read about in passing before, however there were some moments I turned to Pharr, Humphreys & Jakob’s Physically Based Rendering: From Theory to Implementation for a deeper dive into topics. I think some natural extensions to this project would be:

  • Simply let it run longer to get a prettier image
  • Convert some of the functions to CUDA kernels and run it in parallel on the GPU
  • Maybe try and use OptiX/RTX style “OnHit”, “OnMiss”, “OnAny” functions to mimic their APIs
  • Try using importance sampling to increase convergence speed
  • Develop some BxDF functions
  • Millions of other techniques to generally improve performance and quality
  • OH! And I really want to write a ray-tracer in CMake… I recon I’d have to be the first… maybe for good reason.

But for now I’ll end on a classic Cornell Box

A Traditional Cornell Box
George Tattersall
George Tattersall
Master’s Student in High-Performance Graphics and Games Engineering

My research interests include Computer Graphics, Computer Vision and C++.