Developing an Object Oriented Raytracer in C++

Aug 21, 2020

For a programming class during my studies at the Rotterdam University of Applied Sciences I wrote an object oriented ray tracer in C++. There is support for multiple types of objects, diffuse and reflection, multiple light sources and a scene reader.

I have rendered the same scene with different resolutions and samples per pixel. Samples per pixel refers to the number of times a ray is shot through every pixel. For every sample, a ray is shot through a slightly different point in the pixel.


Render time for the cornell box on a i5-8250u processor.

Resolution Sampels Per Pixel Render time Result
100x100 10 0.27s Link
100x100 100 2.32s Link
100x100 1000 23.93s Link
100x100 10000 4m34s Link
500x500 10 6.38s Link
500x500 100 1m7s Link
500x500 1000 11m27s Link
500x500 10000 1h54m36s Link
1000x1000 10 28.16s Link
1000x1000 100 4m41s Link
1000x1000 1000 45m58s Link


  • Support for Spheres, Cubes and Planes
  • Diffuse and reflection
  • Multiple lights
  • Movable camera with a user controlled Field of View (FoV) and position
  • Scene reader using JSON


The ray tracer is build using Object-oriented programming (OOP). For example, a parent class (BasicObject) was created for all objects to be placed in the scene. The different objects are derived from this parent class (Cube, Sphere and Plane). By using the Parent-Child structure, the child class can inherit functions that are the same for all objects. The full UML can be found here. A simplified UML can be found below.

Simplified UML
Simplified UML

Code & Installation

The source code for the Ray Tracer is available here. The installation process is quite simple. Clone the repository and execute the following command:

$ make
arrow-up icon