Assignment 3-2: PathTracer

Ryan Koh

In this assignment, I completed parts 1 and 2, where I implemented both glass and mirror models with refraction and reflection, as well as microfacet material models with reflection, being able to render different more advanced types of models.

Part 1: Mirror and Glass Materials

In this part, I started by first implementing a function for reflection for mirror materials, before implementing refraction for glass materials. I then implemented a sample function for both types of materials, returning ratios as functions of reflectance and the absolute value of the cos(wi), although for glass material also making use of Schlick's reflection coefficient R to determine whether we reflect or refract on a given surface when we sample.

Below are mirror and glass spheres, rendered at maximum ray depths of 0, 1, 2, 3, 4, 5, and 100 respectfully, at 256 samples per pixel and 4 samples per light:

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 max ray depth of 0, the only thing visible in the scene is the light source, which makes sense as we are not allowing any bounces of light. At max ray depth of 1, we allow for one bounce of light, which makes sense with the scene where we get a slight reflection off the surfaces and most of the room gets lit up and is visible, except the actual surfaces of the spheres still remain dark.

At max ray depth of 2, the mirror gets brighter and we can see the other ball from inside it; however, the glass is still rather dark, since it needs one more bounce of light to actually illuminate it. Interestingly, the ball in the reflection of the mirror is dark as well. At max ray depth of 3, the glass ball is finally illuminated, but the reflection in the mirror is still a little bit darker, as it takes more bounces of light to finally make it reach its more natural looking bright state.

Ray depths of 4 and 5 illuminate the balls more completely as the bounces of light manage to encapsulate the full image. The material of the glass ball and the mirror ball are very distinctly founded, and the effects of the material are fairly noticeable with enough bounces of light. Lastly, at ray depth of 100, we get a slightly brighter image as more bounces are allowed, although the Russian Roulette style will still inevitably truncate the number of bounces to a sizable amount.

Part 2: Microfacet Material

In this part, I implemented the Microfacet BRDF function by writing the NDF and Fresnel term functions as specified by the project spec. From there, I implemented importance sampling of the microfacet BRDF in the shape of the Beckmann NDF in order to get an accurate material model of various images!

Below are renders of the gold dragon, at alpha values of 0.005, 0.05, 0.25, and 0.5 respectively. All are rendered at 128 samples per pixel with 1 sample per light, with a maximum ray depth of 5. Notice that for low values of alpha, the render is darker and more glossy / reflective looking, while for higher values of alpha, the render is brighter and more matte:

alpha = 0.005
alpha = 0.05
alpha = 0.25
alpha = 0.25

Additionally, here is the same copper bunny, rendered first with cosine hemisphere sampling (as provided with the sample code), and then with importance sampling, both at 64 samples per pixel, 1 sample per light, and a maximum ray depth of 5. Notice that although cosine hemisphere sampling works better for diffuse BRDFs, in this case, because of the nature of the microfacet material, the sampling leads to a lot of noise, with barely any convergence in the image. On the other hand, with importance sampling, although there is still noise, its more clearly defined and converges better, to reveal the copper material:

cosine hemisphere
importance

Lastly, I also rendered the bunny using different values of eta and k to replace the copper material with gold instead! I substituted the original values for eta = Spectrum(0.21646, 0.42833, 1.3284) and k = Spectrum(3.2390, 2.4599, 1.8661) to get the following material effect:

golden bunny