Skip to content

Commit

Permalink
Update homework3.md part 3 and 4
Browse files Browse the repository at this point in the history
  • Loading branch information
spark0615 authored Mar 17, 2024
1 parent 0d64eba commit 4bb8799
Showing 1 changed file with 56 additions and 18 deletions.
74 changes: 56 additions & 18 deletions homework3.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,41 +54,79 @@ PLACEHOLDER



# Part 3: Direct Illumination
## Task 1: Diffuse BSDF
## Part 3: Direct Illumination

PLACEHOLDER
In our `estimate_direct_lighting_hemisphere`, we have a number of samples and we want to iterate by that amount. Using `w_out` that was provided and `w_i` and `pdf` that we created, we pass that into the `sample_f` function to get the Lambertian BSDF value. Then, using the Monte Carlo Estimator, we calculate the light for the next ray and interact using the `bvh->intersect` function, summing all the light and dividing by the number of samples.

## Task 2: Zero-bounce Illumination
For `estimate_direct_lighting_importance`, it's similar to the previous function, which is hemisphere, but with a bit of difference. We account for the number of lights in the scene and sample using the `sample_L` function that's in `scene->light`. Based on this, we have an inner for loop that iterates `ns_area_light` times. In the inner loop, we create a next ray that intersects, and using variables we got from `sample_L`, we calculate the amount and sum them up. Additionally, we also want to check if the light is a delta light, and if so, we want to stop the for loop. After the inner loop, we divide the sum of the light amount by the number of iterations and add to the total light sum.

PLACEHOLDER
We also have `zero_bounce_radiance` that simply returns `isect.bsdf->get_emission()`.

## Task 3: Direct Lighting with Uniform Hemisphere Sampling
Both of these function is called by one_bounce_radiance. Depends on the value of `direct_hemisphere` that was defined in the command line. Also, before calling this one_bounce radiance, we want to make sure that we call render the the light source by calling `zero_bounce_radiance` as well.

PLACEHOLDER
*Hemisphere*
![Part 3 Bunny light 1 with H](./assets/images/hw3/part3H1.png)
![Part 3 Bunny light 4 with H](./assets/images/hw3/part3H4.png)
![Part 3 Bunny light 16 with H](./assets/images/hw3/part3H16.png)
![Part 3 Bunny light 64 with H](./assets/images/hw3/part3H64.png)

## Task 4: Direct Lighting by Importance Sampling Lights
<br>

PLACEHOLDER
*Importance*
![Part 3 Bunny light 1 without H](./assets/images/hw3/part3-1.png)
![Part 3 Bunny light 4 without H](./assets/images/hw3/part3-4.png)
![Part 3 Bunny light 16 without H](./assets/images/hw3/part3-16.png)
![Part 3 Bunny light 64 without H](./assets/images/hw3/part3-64.png)

<br>

### Compare analysis
*Hemisphere*
![Part 3 sphere light 4 with H](./assets/images/hw3/part3CH4.png)
*Importance*
![Part 3 sphere light 4 without H](./assets/images/hw3/part3C-4.png)

# Part 4: Global Illumination
## Task 1: Sampling with Diffuse BSDF
Looking at these two pictures, we noticed that importance sampling is less noisy and has better quality of shadows. This is because the light sources on surfaces are more precisely simulated. On the other hand, for our Hemisphere sampling, we noticed that the lighting is more uniform and has higher noise in shadow.

PLACEHOLDER

## Task 2: Global Illumination with up to N Bounces of Light
## Part 4: Global Illumination

PLACEHOLDER
In our `at_least_one_bounce_radiance`, we first check to see if `isAccumBounces` is false. If it is, we consider rendering the indirect lighting based only on `m`. Otherwise, we add `one_bounce_radiance` to `L_out` and proceed. For our Russian Roulette, we use 0.4 as recommended in the specification, and by using `coin_flip`, we determine whether to continue executing the code. If the function returns true, we call `sample_f` using `isect` obtained from the function parameter and pass in `wi`. Then, we check if it intersects with our newly created ray with the current depth minus one. If it does, we calculate `L_out` by calling `at_least_one_bounce_radiance` again, thereby recursively calculating one bounce at a time. In the case of `isAccumBounces` being false, we set `L_out` to equal the latest indirect light calculation.

## Task 3: Global Illumination with Russian Roulette
As seen in the images, when `isAccumBounces` is set to false, we only capture indirect light. For example, at `-m 1`, we only see light that has bounced once, meaning we should not see the light source, which we don't. In contrast, when `isAccumBounces` is true, we can see the light source as well as walls/bunny that have been illuminated, because these include one-bounce lights.

PLACEHOLDER
For a high number of bounces, such as 100, we should not see a difference beyond the 10th bounce because, at 100 bounces, the radiance becomes so minimal or nonexistent that further bouncing is effectively inconsequential.

## Task 4: Direct Lighting by Importance Sampling Lights
*CBbunnies with mth-bounce with isAccumBounces True and 2048 samples*
![Part 4 Bunny -m 0](./assets/images/hw3/bunny0.png)
![Part 4 Bunny -m 1](./assets/images/hw3/bunny1.png)
![Part 4 Bunny -m 2](./assets/images/hw3/bunny2.png)
![Part 4 Bunny -m 3](./assets/images/hw3/bunny3.png)
![Part 4 Bunny -m 4](./assets/images/hw3/bunny4.png)
![Part 4 Bunny -m 5](./assets/images/hw3/bunny5.png)

PLACEHOLDER
<br>

*CBbunnies with mth-bounce with isAccumBounces False and 2048 samples*
![Part 4 Bunny -o 0 -m 0](./assets/images/hw3/bunny0.png)
![Part 4 Bunny -o 0 -m 1](./assets/images/hw3/bunny5False1.png)
![Part 4 Bunny -o 0 -m 2](./assets/images/hw3/bunny5False2.png)
![Part 4 Bunny -o 0 -m 3](./assets/images/hw3/bunny5False3.png)
![Part 4 Bunny -o 0 -m 4](./assets/images/hw3/bunny5False4.png)
![Part 4 Bunny -o 0 -m 5](./assets/images/hw3/bunny5False5.png)

<br>

*Russian Roulette*
![Part 4 Bunny Russian Roulette -m 0](./assets/images/hw3/part4R0.png)
![Part 4 Bunny Russian Roulette -m 1](./assets/images/hw3/part4R1.png)
![Part 4 Bunny Russian Roulette -m 2](./assets/images/hw3/part4R2.png)
![Part 4 Bunny Russian Roulette -m 3](./assets/images/hw3/part4R3.png)
![Part 4 Bunny Russian Roulette -m 4](./assets/images/hw3/part4R4.png)
![Part 4 Bunny Russian Roulette -m 100](./assets/images/hw3/part4R100.png)


<br>



Expand Down

0 comments on commit 4bb8799

Please sign in to comment.