Taiki Yoshino, David Choi
University of California San Diego, Computer Scinece and Engineering
CSE167 Computer Graphics (2024 Winter)
Used Tools: C++, OpenGL
We implemented ray tracing algorithm (Whitted 1980) from scratch in C++. Thoese rendering includes the transformation of spheres and triangles, a single point light source, a maximum of five reflections, and material properties.
Additionally, we implemented a Bounding Volume Hierarchy to speed up the rendering process. This acceleration structure halved the rendering time for scene 2 from 20 minutes to 10 minutes, and significantly reduced the rendering time for scene 4 (+50K vertices) from roughly 14 hours to just 2.5 hour. For those implementing bounding volume heirarchy in the future its worth noting that if only 1/4 of your image is rendering properly chances are you just need to check maxT and minT for you bounding volume intersection.
Scene 1
Scene 2
Scene 3
Scene 4
Ray Tracing Overview (NVIDIA’19):
Code Snippet:
RayTrace(Camera cam, Scene scene, int width, int height)
{
Image image = new Image (width, height);
for(int h = 0; h < height; h++){
for(int w = 0; w < width; w++){
Ray ray = RayThruPixel (cam, h, w);
Intersection hit = Intersect (ray, scene);
image[h][w] = FindColor (hit);
}
}
return image;
}
Bounding Volume Hierarchy: (BVH)

Testing every primitive for ray intersection is extremely slow as the number of objects increases. An acceleration structure efficiently selects only some potential primitives for intersection with the ray. BVH first builds a hierarchy of bounding volumes as a binary tree and uses it to accelerate ray intersection. BVH allows the ray to find the intersection in at most O(log(n)).