Skip to content

Commit

Permalink
task 3 images updated
Browse files Browse the repository at this point in the history
  • Loading branch information
christyquang authored Mar 19, 2024
1 parent 2da9860 commit 01c2bfa
Showing 1 changed file with 61 additions and 32 deletions.
93 changes: 61 additions & 32 deletions hw3/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -422,39 +422,91 @@ <h3 align="middle">Task 3: Direct Lighting with Uniform Hemisphere Shading</h3>
</p>

<p>
Below are images of running `./pathtracer -t 8 -s 16 -l 8 -H -f CBbunny_H_16_8.png -r 480 360 ../dae/sky/CBbunny.dae`, `./pathtracer -t 8 -s 64 -l 32 -m 6 -H -f CBbunny_H_64_32.png -r 480 360 ../dae/sky/CBbunny.dae` and `./pathtracer -t 8 -s 64 -l 32 -m 6 -H -f CBempty.png -r 480 360 ../dae/sky/CBspheres_lambertian.dae` with uniform hemisphere sampling.
Below are images of running <code>./pathtracer -t 8 -s 16 -l 8 -H -f CBbunny_H_16_8.png -r 480 360 ../dae/sky/CBbunny.dae</code>, <code>./pathtracer -t 8 -s 64 -l 32 -m 6 -H -f CBbunny_H_64_32.png -r 480 360 ../dae/sky/CBbunny.dae</code> and <code>./pathtracer -t 8 -s 64 -l 32 -m 6 -H -f CBempty.png -r 480 360 ../dae/sky/CBspheres_lambertian.dae</code> with uniform hemisphere sampling.
</p>

<div style="display: flex; justify-content: space-between;">

<div style="flex: 1; margin-right: 10px; text-align: center;">
<img src="images/CBbunny_H_16_8-3.3.png" width="100%" />
<p>
<code>CBbunny_H_16_8-3.3.png</code>
<code>CBbunny_H_16_8.png</code>
</p>
</div>
<div style="flex: 1; margin-left: 10px; text-align: center;">
<img src="images/CBbunny_H_64_32-3.3.png" width="100%" />
<p>
<code>CBbunny_H_64_32-3.3.png</code>
<code>CBbunny_H_64_32.png</code>
</p>
</div>
</div>

<br><br>

<div style="text-align: center;">
<img src="images/CBspheres_lambertian-3.3.png" width="750px" />
<p>Screenshot of <code>../dae/sky/CBspheres_lambertian.dae</code></p>
</div>

<hr>

<h3 align="middle">Task 4: Direct Lighting by Importance Sampling Lights</h3>
<hr>
<p>
Importance sampling is similar to uniform hemisphere sampling with the exception of now iterating through all the lights via <code>scene->lights.begin()</code>. First, we need to check whether <code>is_delta_light()</code> returns true if the light is a point light source. This is because if we sample a point light source, the ray's direction doesn't matter since the outgoing light is the same, hence why only one sample is needed. Otherwise, <code>num_samples</code> is equal to <code>ns_area_light</code>.
</p>

<p>
While still iterating through the lights, we now need to iterate through all of the samples for that light. We created a new vector <code>L</code> assigned to the output of calling <code>sample_L</code>, which also sets <code>wi</code>, <code>distToLight</code> and <code>pdf</code>. Following the same steps in uniform hemisphere sampling, we generated a new sample <code>Ray</code> (<code>new_ray</code>) and set it's <code>min_T</code> and <code>max_T</code> values to <code>EPS_F</code> and <code>dist - EPS_F</code> respectively. Afterwards, we created a new <code>Intersection</code> and checked if there was an intersection by using <code>intersect</code>.
</p>

<p>
If there isn't an intersection, we calculated the \( f_r \) to compute the reflection equation to get the outgoing lighting. This is because if there was an intersection, we don't want to illuminate it because of the previous intersection. We added \( \frac{{L_i \times f_r \times \cos(\theta)}}{{\text{pdf}}} \) to \( L_{\text{out}} \) and after iterating through all of the samples per light, we normalized the outgoing light by dividing by \( \text{num_samples} \). This was then added to \( \text{result} \) (final \( L_{\text{out}} \)) and returned.
</p>

<p>
Below are images generated when running <code>./pathtracer -t 8 -s 64 -l 32 -m 6 -f {filename}.png -r 480 360 ../dae/sky/{filename}.dae</code> for importance sampling lights.
</p>

<div style="display: flex; justify-content: space-between;">

<div style="flex: 1; margin-right: 10px; text-align: center;">
<img src="images/bunny_64_32-3.4.png" width="100%" />
<p>
<code>../dae/sky/CBbunny.dae</code>
</p>
</div>
<div style="flex: 1; margin-left: 10px; text-align: center;">
<img src="images/CBbunny-sample4.png" width="100%" />
<p>
<code>../dae/sky/CBbunny.dae</code>, 4 light rays
</p>
</div>
</div>

<br><br>

<div style="text-align: center;">
<img src="images/dragon_64_32-3.4.png" width="750px" />
<p>Screenshot of <code>../dae/sky/dragon.dae</code></p>
</div>

<p>
Using light importance sampling, we can also compare the noise levels in soft shadows when rendering with 1, 4, 16, and 64 light rays (the <code>-l</code> flag) and 1 sample per pixel (the <code>-s</code> flag) for <code>../dae/sky/CBbunny.dae</code>. When there are more light rays, we can see that there is less noise in the rendered images. The shadows become more smooth and the edges are less rigid because with less light rays, each shadow point is clearer. With more light rays, there is a greater range, allowing for more variation in the shadows.
</p>

<div style="display: flex; justify-content: space-between;">

<div style="flex: 1; margin-right: 10px; text-align: center;">
<img src="images/CBbunny-sample1.png" width="100%" />
<p>
<code>CBbunny-sample1.png</code>
<code>../dae/sky/CBbunny.dae</code>, 1 light ray
</p>
</div>
<div style="flex: 1; margin-left: 10px; text-align: center;">
<img src="images/CBbunny-sample4.png" width="100%" />
<p>
<code>CBbunny-sample4.png</code>
<code>../dae/sky/CBbunny.dae</code>, 4 light rays
</p>
</div>
</div>
Expand All @@ -466,39 +518,16 @@ <h3 align="middle">Task 3: Direct Lighting with Uniform Hemisphere Shading</h3>
<div style="flex: 1; margin-right: 10px; text-align: center;">
<img src="images/CBbunny-sample16.png" width="100%" />
<p>
<code>CBbunny-sample16.png</code>
<code>../dae/sky/CBbunny.dae</code>, 16 light rays
</p>
</div>
<div style="flex: 1; margin-left: 10px; text-align: center;">
<img src="images/CBbunny-sample64.png" width="100%" />
<p>
<code>CBbunny-sample64.png</code>
<code>../dae/sky/CBbunny.dae</code>, 64 light rays
</p>
</div>
</div>
<hr>

<h3 align="middle">Task 4: Direct Lighting by Importance Sampling Lights</h3>
<hr>
<p>
Importance sampling is similar to uniform hemisphere sampling with the exception of now iterating through all the lights via <code>scene->lights.begin()</code>. First, we need to check whether <code>is_delta_light()</code> returns true if the light is a point light source. This is because if we sample a point light source, the ray's direction doesn't matter since the outgoing light is the same, hence why only one sample is needed. Otherwise, <code>num_samples</code> is equal to <code>ns_area_light</code>.
</p>

<p>
While still iterating through the lights, we now need to iterate through all of the samples for that light. We created a new vector <code>L</code> assigned to the output of calling <code>sample_L</code>, which also sets <code>wi</code>, <code>distToLight</code> and <code>pdf</code>. Following the same steps in uniform hemisphere sampling, we generated a new sample <code>Ray</code> (<code>new_ray</code>) and set it's <code>min_T</code> and <code>max_T</code> values to <code>EPS_F</code> and <code>dist - EPS_F</code> respectively. Afterwards, we created a new <code>Intersection</code> and checked if there was an intersection by using <code>intersect</code>.
</p>

<p>
If there isn't an intersection, we calculated the \( f_r \) to compute the reflection equation to get the outgoing lighting. This is because if there was an intersection, we don't want to illuminate it because of the previous intersection. We added \( \frac{{L_i \times f_r \times \cos(\theta)}}{{\text{pdf}}} \) to \( L_{\text{out}} \) and after iterating through all of the samples per light, we normalized the outgoing light by dividing by \( \text{num_samples} \). This was then added to \( \text{result} \) (final \( L_{\text{out}} \)) and returned.
</p>

<p>
Below are images generated when running <code>./pathtracer -t 8 -s 64 -l 32 -m 6 -f {filename}.png -r 480 360 ../dae/sky/{filename}.dae</code> for importance sampling lights.
</p>

<p>
Using light importance sampling, we can also compare the noise levels in soft shadows when rendering with 1, 4, 16, and 64 light rays (the <code>-l</code> flag) and 1 sample per pixel (the <code>-s</code> flag) for <code>../dae/sky/CBbunny.dae</code>. When there are more light rays, we can see that there is less noise in the rendered images. The shadows become more smooth and the edges are less rigid because with less light rays, each shadow point is clearer. With more light rays, there is a greater range, allowing for more variation in the shadows.
</p>

<p>
<u>Uniform Hemisphere Sampling vs Light Sampling</u>
Expand All @@ -513,13 +542,13 @@ <h3 align="middle">Task 4: Direct Lighting by Importance Sampling Lights</h3>
<div style="flex: 1; margin-right: 10px; text-align: center;">
<img src="images/bunny_1_1-3.4.png" width="100%" />
<p>
<code>bunny_1_1-3.4.png</code>
<code>../dae/sky/CBbunny.dae</code> with uniform hemisphere sampling
</p>
</div>
<div style="flex: 1; margin-left: 10px; text-align: center;">
<img src="images/bunny_64_32-3.4.png" width="100%" />
<p>
<code>bunny_64_32-3.4.png</code>
<code>../dae/sky/CBbunny.dae</code> with direct lighting sampling
</p>
</div>
</div>
Expand Down

0 comments on commit 01c2bfa

Please sign in to comment.