Assignment 3: PathTracer

Lucy Wan and Maleny Ruiz

In this project, we add glass, mirror, and microfacet materials to our ray tracer.

Part 1: Mirror and Glass Materials

To implement this project, we first implemented the reflect function where we set the outgoing ray by reflecting the incoming ray over the normal vector in object space. We then call our reflect function in the sample_f function for our mirror material. Afterwards we implement refract using Snell's law to set our outgoing ray and return false if total internal refraction occurs (otherwise we return true). Then for the sample_f function of the mirror material, we return transmittance / abs_cos_theta(*wi) / eta^2. However if total internal reflection occurs we return an empty vector. Next we implement the sample_f function for our glass material by computing Schlick's reflection coefficient R and reflecting with probability R (return R * reflectance / abs_cos_theta(*wi)) and refracting with probability 1 - R (return R * reflectance / abs_cos_theta(*wi)). If there is total internal reflection we reflect and set the pdf to 1.

When implementing the sample_f function for our glass material, we ran into several bugs. The first bug was that the figure in the rendering of the CBLucy image was completely dark. We solved this issue by remembering to call the reflect and refract functions in our code. However, afterwards, the figure had a dark texture. We overcame this bug by reviewing our code and looking over the conceptual details for Schlick's reflection coefficient and realizing that we need to take the cosine of the dot product of the outgoing ray and the normal since the dot product only gives us an angle.

Max_ray_depth = 0
Max_ray_depth = 1
Max_ray_depth = 2
Max_ray_depth = 3
Max_ray_depth = 4
Max_ray_depth = 5
Max_ray_depth = 100

At a max_ray_depth of 0, the image is completely black except for the light source since light isn't emanating off of any surface. At a max_ray_depth of one, there is some reflection of light from the spheres but not enough to notice their material (glass and mirror). This is because the light is only reflecting off the sphere towards the camera but not back at the spheres. At a max_ray_depth of two, the sphere on the left starts to properly show its mirror material by reflecting the rest of the room. This is because there's not some light being reflected back at the spheres. The sphere on the right on the other hand still looks very much like it does with one bounce of light except if you look closely you can see a dim reflection of the rest of the room as well as a bit more transparency (due to itss glass material). At a max_ray_depth of three, the mirror and glass material of the spheres becomes much more apparent, with the right sphere no longer looking dim and the left sphere looking less dim. This is because there's now enough light for refraction to properly show. At a max_ray_depth of four, the image looks almost identical to the previous image except the reflection of the glass sphere on the mirror sphere looks transparent instead of dim. This is because there's now enough light for the reflection of the glass sphere to show properly. At a max_ray_depth of five, there's not much of a difference with max_ray_depth of four. At a max_ray_depth of one hundred, the image doesn't look too different from the previous two images. These images look about the same since after a certain point, more bounces of light only minorly enhance the image.

Part 2: Microfacet Materials

To implement microfacet material, specifically isotropic rough conductors, we first had to implement the evaluation function MicrofacetBSDF::f = (F(wi) * G (wo, wi) * D(h) ) / (4 * (n • wo) * (n • wi)) that includes all of the other parts to calculate the microfacet material look. MicrofacetBSDF::D is the normal distribution function that takes in the half vector between wo and wi and calculates the Beckmann distribution with the alpha value of the roughness of the macro surface and the theta value of the half vector. MicrofacetBSDF::D = (e^(-tan^2(θh) / α^2) / (π * α^2 * cos^4(θh)). MicrofacetBSDF::F is the Fresnel term that is calculated with the RGB color channels. MicrofacetBSDF::F = (Rs + Rs) / 2 where Rs = ((n^2 + k^2) - 2*n*cos(θi) + cos^2(θi)) / ((n^2 + k^2) + 2*n*cos(θi) + cos^2(θi)) and Rp = ((n^2 + k^2)*cos^2(θi) - 2*n*cos(θi) + 1) / ((n^2 + k^2)*cos^2(θi) + 2*n*cos(θi) + 1) where the n and k values come from the color's wavelengths and their n and k values for RGB channels. That was what was used to evaluate the Microfacet BRDF value. This was used at the end of the importance sampling. We calculated the combined pdf using pw(h) / (4*(wi • h) where h is the microfacet sampled pdf of Theta and Phi. wi is the reflection of wo and h.

For this part, we had some arithmetic errors that didn't render the correct images. They were too bright or too dark and didn't match the metal material. We went to office hours to find these arithmetic errors. We also isolated the final sample by using hemisphere sampling to see if the issue was at the end or the beginning. We found that we didn't use a dot product when reflecting at the end.

Alpha = 0.005
Alpha = 0.05
Alpha = 0.25
Alpha = 0.5

Using a larger alpha value makes the dragon and the gold color look more matte and not shiny even though the light is still reflective on the dragon. As we decrease the alpha value, the dragon and the gold are more shiny and start to get darker. The dragon starts to get more of a buff metallic look. The room also starts to get some noise. The colors of the room are also a little more pronounced as we decreased the alpha value because the dragon is more shiny and more reflective.

Hemisphere Sampling
Importance Sampling

Using hemisphere sampling with the bunny the bunny has more noise on it as well as the room. The gold on the bunny isn't really prominent compared to all the noise and black spots. It doesn't give enough information to show the full gold on the bunny. This is why importance sampling shows a better view of the gold on the bunny. Importance sampling shows a more metallic look and more of a fuller picture with less noise.

Silver (au) Dragon

Partner Refelction

For this project, we split up the work and each did a part. We kept each other updated on where we were and tried to go to project parties and office hours together. We then were able to tell eachother what we did and learned a lot from teaching eachother and listening to each other.

https://cal-cs184-student.github.io/sp22-project-webpages-maleny25/proj3-2/index.html