Prior to this final project, I realized that my ray tracer performed slowly when rendering obj meshes. I wanted the ability to render obj meshes more efficiently so that I could render more complex scenes. To improve performance, I implemented a BVH spatial data structure. My BVH representation is a binary tree. Each node has a bounding box that encloses all the geometry beneath it. Each node also has left and right pointers to nodes representing smaller regions of space. To construct the BVH, triangles are sorted by their center coordinates and then split into two groups (these groups are assigned to the left and right attributes of a node). The subdivision repeats until each triangle is a leaf of the tree.
To simulate global illumination (indirect lighting/color bleeding), I implemented Monte Carlo sampling. When a ray is shot into the scene, I generated sample points using cosine weighting to determine where to aim the scattered rays. The colors obtained by these secondary rays are then averaged and combined with the color of the object that was initially hit. My ray tracer allows me to specify how many sample points to generate and how many bounces to allow. I focused specifically on scenes with purely diffuse surfaces.
Below are some extra renders of scenes I created throughout CSC 473.