CS413 Assignment 5: Acceleration Data-structures

Scene Setup:
# Light is at [400,400,400], color [1,1,1]
# Eye [0,.2,.35], Look-at [0,0,0], Up [0,1,0]
# Image plane is at distance of 1 from eye, Dimensions 2x2 (width and height)
# Development Platform: Visual C++ 8, Release build
Source Code: reTracer -->

Results

Implemented a binary tree data structure (kd-tree) to handle triangle meshes. The meshes are loaded from a file (.obj) and converted into an internal TriMesh objects. Each of these objects have its own acceleration data structure. On the scene each object (Sphere/TriMesh) have a bounding volume (Axis-Aligned Bounding Box) that is checked first for intersection. If the object is hit and it is a TriMesh, it uses its data structure to get a list of leaf nodes with Triangles to test for intersections.

I used a simple Binary tree with the dividing planes placed in the middle of nodes. This is not the best way, but the implementation is flexible to allow for intelligent placement of the plane based on number of triangles in the node and space.

Also used the baricentric coordinates (alpha, beta, gamma values) calculated for triangle intersection to interpolate the per vertex normals. This results in a much smoother shading over the edges.

Test Setup

Meshes: Three meshes (TriMesh) are loaded onto the scenes and placed in different locations.

Total Triangles in the scene: 565,203

Total Rays Traced: 1,048,576 (4 samples per pixel)

Acceleration OFF ON
Intersections Tested (Unable to calculate) 652,302,723
Time Taken 152.7 mins 73.9 sec

Observations:

  1. The level of complexity grows with the number of samples used per pixel. Therefore, the best way to accelerate ray tracing is to reduce the number of intersection tests needed to perform for each ray.
  2. Clearly acceleration data structure is significantly reducing the time to render the scene by means of using less intersection tests.
  3. Bounding box test works really well with multiple objects in the scene. Especially if the object takes up a relatively smaller proportion on the screen.
  4. The Binary Tree data structure works better with longer depths with a small amount of object in each leaf node. However, the more the depth of the tree it takes longer to compute it, and needs more bounding box tests with the ray.