This is an implementation of an accelerated raytracer using a kd-tree with a SAH loosely based on . This was a project for an advanced computer graphics course during my master’s studies, implemented in C++ using GLM, SDL2 and Assimp.
A simple scene based on the Cornell box. It contains 9 primitives and has 49 point lights in an area to provide smooth shadows and is rendered using a resolution of 1024 by 1024.
As the number of primitives is very low the usage of a kd-tree did not have any impact on the number of computed intersections. However, the runtime is greatly affected, with the additional overhead of the kd-tree search adding extensive computational effort.
This is a more complicated scene with 12211 primitives representing a house and 4 spread out lights. The house was modelled in Blender, exported as a binary GLTF file and rendered at a resolution of 2048 by 2048.
Compared to before, this scenario is reversed. As can be seen, the number of intersections and runtime improvements profit substantially from the kd-tree optimization. While the construction of the kd-tree adds about 0.6 seconds to the initialization time, the impact on the overall runtime is inconsiderable.