Assignment 3: PathTracer

Yanghao Cheng

Use this section to write an overview of the assignment. All of the text in your write-up should be in your own words. If you need to add additional HTML features to this document, you can search the http://www.w3schools.com/ website for instructions. To edit the HTML, you can just copy and paste existing chunks and fill in the text and image file names appropriately.

The website writeup is intended to be a self-contained walkthrough of the assignment: we want this to be a piece of work which showcases your understanding of relevant concepts through both mesh images as well as written explanations about what you did to complete each part of the assignment. Try to be as clear and organized as possible when writing about your own output files or extensions to the assignment. We want to understand what you've achieved and how you've done it!

If you are well-versed in web development, feel free to ditch this template and make a better looking page. Just make sure that you include all the components as we've laid them out here.

Part 1: Ray Generation and Intersection

This part contains generating rays from the camera and testing if the ray intersect with primitive, i.e. triangles and spheres. First, I compute the direction of the ray in camera space. Then, the direction is transformed to world space. This direction is d of the ray. After that, the o of the ray is set by the position of the camera in space. Finally, the max and min of t of the ray in set by the near and far clip of the camera.
To test intersection with a triangle, I implement both plane test and the Moller Trumbore Algorithm, although at the end, I decide to use Moller Trumbore beacause it is more convinent. With the output of Moller Trumbore, I test if t is in between the range of min and max_t of the ray. If that is true, the ray hit the plane of the triangle. Finally, I test if b1 and b2 are both in range 0 to 1 and add up less than 1. It that is true, the hit point is in the triangle.
The detail of Moller Trumbore is a simple fomula:

Credit: https://cs184.eecs.berkeley.edu/sp20/lecture/10-20/ray-tracing
o and d are of the ray, and p0, p1, and p2 are the three vertices of the triangle.

Here are some results:

Part 2: Bounding Volume Hierarchy

Constructing a BVH is simple at a higher level, but it involves many detail to consider. Overall, my BVH construction algorithm is a recursive algorithm. No matter which case it is, it first construct the bounding box with the given input primitives. Then it is the base case if the size of input is less than a constant, max_leaf_size, otherwise it is the recursive case.
For base case, it simply set the node to be a leaf node, NULL children, and its start and end iterator is same as the input.
The juicy part is the recursive case, first it need to identify the axis that interests the most, i.e. the longest axis. An interesting implimentation here is that I use 0, 1, and 2 to identify x, y, and z, respectively. The advantage is that I can use [] operator to select the desired axis, whereas hard-coding x, y, and z into the code. Using simple heuristic, mid-point of the spanning range, to pick the split point, it "sorts" the input list in-place. It roughly group the primitives to the left of the split point, putting them in the lower part of the list, and the primitives to the right in the higher part. In this way, the following recursive calls can simply take their respective intervels of the list. And it saves a lot of memory.

BVH acceleration makes rendering complex geometries faster. I wouldn't be partient enough to wait for the above image to render without BVH. Talking about a less complex geometry, cow.dae, it takes ~40 seconds to render without BVH. In live-render mode, it shows that the image is rendered in blocks. On the other hand, the cow can be rendered in a blink of eye with BVH.

Part 3: Direct Illumination

There are two kinds of implementation of the direct light sampling in the program. Uniform sampling converges slowly and gives lots of noise before then, whereas importance sampling converges faster. In uniform sampling, the ray being traced will be uniformly sampled in the hemisphere. In importance sampling, the next ray will go directly to one of the light source, the final radiance will be adjusted by the probability density function.

Comparason

No Super Sampling
x32 Super Sampling
x1 Ray Sample per Light
x16 Ray Sample per Light

Part 4: Global Illumination

Part 5: Adaptive Sampling

Results Caption: my bunny is the bounciest bunny

Here is an example of how to include a simple formula:

a^2 + b^2 = c^2

or, alternatively, you can include an SVG image of a LaTex formula.

This time it's your job to copy-paste in the rest of the sections :)

A Few Notes On Webpages

Here are a few problems students have encountered in the past. You will probably encounter these problems at some point, so don't wait until right before the deadline to check that everything is working. Test your website on the instructional machines early!