Lime raytracer
A CPU raytracer.
One of my school assignments was to create a raytracer without flat surfaces, that runs on the CPU at a reasonable framerate. I had 8 weeks to complete this project and the entire project is made using C++ and a template for rendering the graphics to the screen and getting input from the user. The focus of the project was to learn the fundamentals of raytracing and how to take something as performance-heavy as raytracing and how to make it more performant.
Table of contents
Raytracing
The focus was to learn about the algorithms and math associated with withed style raytracing. The project includes the following:
- Whitted-style raytracing
- Monte Carlo raytracing
- Raytracing a sphere
- Raytracing an ellipsoid
- Making use of point lights
- Making use of area lights
- Diffuse materials
- Reflective materials
- Dielectric materials
- Applying beer’s law to Dielectrics
Bounding volume hierarchy
Next to creating a raytracer, we also needed to work on making it more performant. One way I got a lot of performance out of my raytracer was by applying an optimization structure to my scene to make it easier to see what geometry the rays are colliding with. For my optimization structure, I used the following:
- Creating a Bounding volume hierarchy that contains all the geometry in the scene
- Making use of Surface Area Heuristics to find the optimal split for each bounding volume
Multithreading
To squeeze a bit more performance out of my raytracer I decided to investigate multithreading. In the end, I was able to setup a job system that collects jobs for rendering parts of the frame, once the entire frame is rendered it is displayed to the user, and the jobs for the next frame are provided to the job system.
Demo shots





