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 -->
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.
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: