The ray tracing can be divided into two main sections:
1. Intersection algorithm
2. Trace
Section1:
This section is based on the paper "Real Time KD-Tree Construction on Graphics Hardware".
Input of this section is a triangle list.
When constructing a KD-tree, we should recursively split current node into two parts. The coordinate part is down in CPU and is the BFS of a tree.
The parallelism is exploited as such:
1. compute AABB for triangles in parallel.
2. Split nodes at the same level of a tree in parallel.
3.For larger nodes, Calculate the bounding box of each node in parallel. Divide triangles in each node into chunks, then all chunks in all nodes are processed parallel. Finishing the chunk bounding boxes, use the same method to get the bounding box for each node. This process uses the reduction algorithm.
4. For smaller nodes, it is really clever to use bit masks. I such manner, reduction algorithm find its place again.
Section 2:
Apparently, each pixel can be processed parallel. However, a big problem is the recursion in ray tracing. Now, I haven't started to work on this problem.
Problem to be solved:
1.How to import meshes into my program first. Maybe I can import meshed from Maya.
2. Figure out more details about the KD tree. Like SAH cost, spatial median splitting, empty space maximizing, how to incorporate reduction.