Skip to content

Commit

Permalink
Update notes
Browse files Browse the repository at this point in the history
  • Loading branch information
IskXCr committed Sep 16, 2023
1 parent 002555d commit 67a2e11
Show file tree
Hide file tree
Showing 44 changed files with 762 additions and 88 deletions.
2 changes: 1 addition & 1 deletion GAMES-101/markdown/Lecture12.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GAMES101 Lecture 12 - Geometry 3
# GAMES101 Lecture 12 - Geometry 3 (Mesh Operations and Shadow Mapping)

[GAMES101_Lecture_12.pdf](https://sites.cs.ucsb.edu/~lingqi/teaching/resources/GAMES101_Lecture_12.pdf)

Expand Down
2 changes: 1 addition & 1 deletion GAMES-101/readable-html/Lecture12.html

Large diffs are not rendered by default.

170 changes: 85 additions & 85 deletions GAMES-101/readme.md
Original file line number Diff line number Diff line change
@@ -1,85 +1,85 @@
# GAMES101 - Notes

## Introduction to This Course

GAMES101 (2020-02), or **Introduction to Computer Graphics**, conducted by Prof. Lingqi Yan, is an introductory course that explores the fundamentals of Computer Graphics. This comprehensive offering provides students with a solid foundation in essential principles and techniques used in CG, including rendering (both rasterization and modern ray-tracing), geometry, and animation. Additionally, the course showcases the captivating nature of the field and highlights cutting-edge research conducted by leading experts. Students are expected to gain a deeper understanding of visually stunning virtual environments and stay informed about the latest advancements in CG.

[Course Website - GAMES101](https://sites.cs.ucsb.edu/~lingqi/teaching/games101.html)

The corresponding English version can be found at [Course Website - CS180/CS280 - Introduction to Computer Graphics](https://sites.cs.ucsb.edu/~lingqi/teaching/cs180.html).

## About This Repository

This repository contains my notes for GAMES101 conducted by Prof. Lingqi Yan.

The purpose of this repository is to track personal progress.

According to the policy listed in the slide of the first week, this public repository is uploaded only for educational/referential usages and discussions.

It is VIOLATING THE POLICY specified in GAMES101 to directly copy these referential materials and use as a student's own solution without having them walked through by itself first.

## About Notes and Copyright

### How do I read notes online?

So far GitHub markdown preview cannot provide satisfying experience on physical formulae. We compiled these notes into HTML format for easy access.

Online reading experience currently relies on the GitHub Pages service. Below you will find the links to them.

### Online Notes (Based on GitHub Pages)

[Lecture01 - Introduction to Computer Graphics](./readable-html/Lecture01.html)

[Lecture02 - Basic Linear Algebra](./readable-html/Lecture02.html)

[Lecture03 - Transformation](./readable-html/Lecture03.html)

[Lecture04 - Transformation Cont.](./readable-html/Lecture04.html)

[Lecture05 - Rasterization 1](./readable-html/Lecture05.html)

[Lecture06 - Rasterization 2](./readable-html/Lecture06.html)

[Lecture07 - Shading 1](./readable-html/Lecture07.html)

[Lecture08 - Shading 2](./readable-html/Lecture08.html)

[Lecture09 - Shading 3](./readable-html/Lecture09.html)

[Lecture10 - Geometry 1](./readable-html/Lecture10.html)

[Lecture11 - Geometry 2](./readable-html/Lecture11.html)

[Lecture12 - Geometry 3](./readable-html/Lecture12.html)

[Lecture13 - Ray Tracing 1](./readable-html/Lecture13.html)

[Lecture14 - Ray Tracing 2](./readable-html/Lecture14.html)

[Lecture15 - Ray Tracing 3](./readable-html/Lecture15.html)

[Lecture16 - Ray Tracing 4](./readable-html/Lecture16.html)

[Lecture17 - Materials and Appearances](./readable-html/Lecture17.html)

[Lecture18 - Advanced Topics in Rendering](./readable-html/Lecture18.html)

[Lecture19 - Cameras, Lenses and Light Fields](./readable-html/Lecture19.html)

[Lecture20 - Color and Perception](./readable-html/Lecture20.html)

[Lecture21 - Animation](./readable-html/Lecture21.html)

[Lecture22 - Animation Cont.](./readable-html/Lecture22.html)


### How do I read notes using local tools?

The recommended reader is Typora, which is a commercial software (and has a not-that-good reputation in the open source community).

However, it comes with rich support in inline math and exporting markdown to HTML. The HTML files you see in this folder are exported by Typora.


### Notes and Copyright Disclaimer

COPYRIGHT DISCLAIMER: If not otherwise specifically mentioned, all the figures inside the notes are captured/created from slides. If you have found a figure without reference, then either it is from the slides and made by the author, or the source has been mentioned in the slides (for some reason they are not mentioned inside the notes). **The author of these notes doesn't own the COPYRIGHT of them, and there is NO copyright infringement intended.**
# GAMES101 - Notes

## Introduction to This Course

GAMES101 (2020-02), or **Introduction to Computer Graphics**, conducted by Prof. Lingqi Yan, is an introductory course that explores the fundamentals of Computer Graphics. This comprehensive offering provides students with a solid foundation in essential principles and techniques used in CG, including rendering (both rasterization and modern ray-tracing), geometry, and animation. Additionally, the course showcases the captivating nature of the field and highlights cutting-edge research conducted by leading experts. Students are expected to gain a deeper understanding of visually stunning virtual environments and stay informed about the latest advancements in CG.

[Course Website - GAMES101](https://sites.cs.ucsb.edu/~lingqi/teaching/games101.html)

The corresponding English version can be found at [Course Website - CS180/CS280 - Introduction to Computer Graphics](https://sites.cs.ucsb.edu/~lingqi/teaching/cs180.html).

## About This Repository

This repository contains my notes for GAMES101 conducted by Prof. Lingqi Yan.

The purpose of this repository is to track personal progress.

According to the policy listed in the slide of the first week, this public repository is uploaded only for educational/referential usages and discussions.

It is VIOLATING THE POLICY specified in GAMES101 to directly copy these referential materials and use as a student's own solution without having them walked through by itself first.

## About Notes and Copyright

### How do I read notes online?

So far GitHub markdown preview cannot provide satisfying experience on physical formulae. We compiled these notes into HTML format for easy access.

Online reading experience currently relies on the GitHub Pages service. Below you will find the links to them.

### Online Notes (Based on GitHub Pages)

[Lecture01 - Introduction to Computer Graphics](./readable-html/Lecture01.html)

[Lecture02 - Basic Linear Algebra](./readable-html/Lecture02.html)

[Lecture03 - Transformation](./readable-html/Lecture03.html)

[Lecture04 - Transformation Cont.](./readable-html/Lecture04.html)

[Lecture05 - Rasterization 1 (Triangles)](./readable-html/Lecture05.html)

[Lecture06 - Rasterization 2 (Anti-aliasing and Z-Buffering)](./readable-html/Lecture06.html)

[Lecture07 - Shading 1 (Illumination, Shading and Graphics Pipeline)](./readable-html/Lecture07.html)

[Lecture08 - Shading 2 (Shading, Pipeline and Texture Mapping)](./readable-html/Lecture08.html)

[Lecture09 - Shading 3 (Texture Mapping and Shadow Mapping)](./readable-html/Lecture09.html)

[Lecture10 - Geometry 1 (Introduction)](./readable-html/Lecture10.html)

[Lecture11 - Geometry 2 (Curves and Surfaces)](./readable-html/Lecture11.html)

[Lecture12 - Geometry 3 (Mesh Operations and Shadow Mapping)](./readable-html/Lecture12.html)

[Lecture13 - Ray Tracing 1 (Whitted-Style Ray Tracing)](./readable-html/Lecture13.html)

[Lecture14 - Ray Tracing 2 (Acceleration and Radiometry)](./readable-html/Lecture14.html)

[Lecture15 - Ray Tracing 3 (Light Transport and Global Illumination)](./readable-html/Lecture15.html)

[Lecture16 - Ray Tracing 4 (Monte Carlo Path Tracing)](./readable-html/Lecture16.html)

[Lecture17 - Materials and Appearances](./readable-html/Lecture17.html)

[Lecture18 - Advanced Topics in Rendering](./readable-html/Lecture18.html)

[Lecture19 - Cameras, Lenses and Light Fields](./readable-html/Lecture19.html)

[Lecture20 - Color and Perception](./readable-html/Lecture20.html)

[Lecture21 - Animation](./readable-html/Lecture21.html)

[Lecture22 - Animation Cont.](./readable-html/Lecture22.html)


### How do I read notes using local tools?

The recommended reader is Typora, which is a commercial software (and has a not-that-good reputation in the open source community).

However, it comes with rich support in inline math and exporting markdown to HTML. The HTML files you see in this folder are exported by Typora.


### Notes and Copyright Disclaimer

COPYRIGHT DISCLAIMER: If not otherwise specifically mentioned, all the figures inside the notes are captured/created from slides. If you have found a figure without reference, then either it is from the slides and made by the author, or the source has been mentioned in the slides (for some reason they are not mentioned inside the notes). **The author of these notes doesn't own the COPYRIGHT of them, and there is NO copyright infringement intended.**
Binary file added GAMES-202/images/Lecture05-img-10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture05-img-11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture05-img-12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture05-img-13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture05-img-8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture05-img-9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture06-img-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture06-img-10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture06-img-11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture06-img-12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture06-img-13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture06-img-14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture06-img-15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture06-img-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture06-img-17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture06-img-18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture06-img-19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture06-img-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture06-img-20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture06-img-21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture06-img-22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture06-img-23.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture06-img-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture06-img-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture06-img-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GAMES-202/images/Lecture06-img-6.png
Binary file added GAMES-202/images/Lecture06-img-7.png
Binary file added GAMES-202/images/Lecture06-img-8.png
Binary file added GAMES-202/images/Lecture06-img-9.png
Binary file added GAMES-202/images/Lecture07-img-1.png
Binary file added GAMES-202/images/Lecture07-img-2.png
Binary file added GAMES-202/images/Lecture07-img-3.png
Binary file added GAMES-202/images/Lecture07-img-4.png
Binary file added GAMES-202/images/Lecture07-img-5.png
Binary file added GAMES-202/images/Lecture07-img-6.png
Binary file added GAMES-202/images/Lecture07-img-7.png
123 changes: 122 additions & 1 deletion GAMES-202/markdown/Lecture05.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,130 @@ To compute the angle, use $\min\left\{\frac{k \cdot \text{SDF} (p)}{p - o}, 1.0\



## II. Shading from Environment Lightning
## II. Shading from Environment Lighting

Environment lighting: Simulate lighting coming from the surroundings of a scene.

![image-20230913185204341](../images/Lecture05-img-8.png)

There are **spherical** maps and **cube** maps.

The environment lighting is used when solving the rendering equation. Environment maps provide **info of incoming radiance** on a specific shading point.

- **General Solution**: Monte Carlo Integration
- Numerical
- Large amount of samples required
- Can be **slow**
- Sampling is not preferred in shaders\* in general: High time complexity.



### The Split Sum Approximation

In the industry, the resulting integral is computed using sampling and summing, thus it is called **split sum** rather than split **integral**.

#### Principle

The split sum approximation **avoids sampling** by approximating the given integral in a way described in Lecture 4:
$$
\int_{\Omega} f(x) g(x) \dd{x} \approx
\underbrace{\frac{\int_{\Omega_G} f(x) \dd{x}}{\int_{\Omega_G} \dd{x}}}_{\substack{\text{The average value} \\ \text{of $f(x)$ over the} \\ \text{effective interval of }g(x)}}
\cdot \int_\Omega g(x) \dd{x}
$$

- **General BRDFs satisfy the requirements for accuracy in all cases**:
- If the BRDF is **glossy**, then $g(x)$ or $f_r(x)$ in the formula, has small support.
- If the BRDF is **diffuse**, then $g(x)$ or $f_r(x)$ in the formula, is smooth.

- *Note the slight edit on* $\Omega_G$.



#### 1st Stage

We approximate the rendering equation as follows:

$$
\begin{equation} \tag{1} \label{eq1}
L_o(\text{p}, \omega_o)
\approx
\frac{
\int_{f_r} L_i (\text{p}, \omega_i) \dd{\omega_i}
} {
\int_{f_r} \dd{\omega_i}
}
\cdot
\underbrace{\int_{\Omega+} f_r(\text{p}, \omega_i, \omega_o) \cos \theta_i \dd{\omega_i}}
_{\text{Do shading without considering lighting}}
\end{equation}
$$

- **Prefiltering** of the environment lighting: Computing the first term $\frac{
\int_{f_r} L_i (\text{p}, \omega_i) \dd{\omega_i}}{\int_{f_r} \dd{\omega_i}}$
- Pre-generating a set of differently filtered environment lighting
- Filter size in-between can be approximated via (trilinear) interpolation.

![image-20230913191319711](../images/Lecture05-img-9.png)

- And then **querying** the pre-filtered environment lighting at $\omega_i$:

![image-20230913191510378](../images/Lecture05-img-10.png)



#### 2nd Stage

Compute the latter part of equation $\ref{eq1}$ by **approximating the surface as a microfacet**, and extract the Fresnel term using the **Schlick's Approximation**:
$$
\begin{equation} \tag{The Microfacet Model}
f(\omega_i, \omega_o) =
\frac{
\text{F}(\omega_i, \textbf{h})
\textbf{G}(\omega_i, \omega_o, \textbf{h})
\textbf{D}(\textbf{h})
}{
4 (\textbf{n}, \omega_i) (\textbf{n}, \omega_o)
}
\end{equation}
$$

$$
\begin{equation} \tag{The Schlick's Approximation}
R(\theta) = R_0 + (1 - R_0)(1 - \cos \theta)^5
\end{equation}
$$

where
$$
R_0 = \left(\frac{n_1 - n_2}{n_1 + n_2}\right)^2.
$$

$$
\begin{equation} \tag{The NDF, Normal Distribution Function}
D(h) = \frac{\exp(\tan^2\theta_h)}{\pi \alpha^2 \cos^4 \theta_h}
\end{equation}
$$

![image-20230913192819390](../images/Lecture05-img-11.png)

**The base color $R_0$ is now extracted**:
$$
\begin{aligned}
\int_{\Omega+} f_r(\text{p}, \omega_i, \omega_o) \cos \theta_i \dd{\omega_i} \approx{} & R_0 \int_{\Omega_+}
\frac{f_r}{F} (1 - (1 - \cos \theta_i)^5) \cos \theta_i \dd{\omega_i} + \\
& \int_{\Omega_+} \frac{f_r}{F} (1 - \cos \theta_i)^5 \cos \theta_i \dd{\omega_i}
\end{aligned}
$$
and both integrals can be **precomputed**:

![image-20230913193058987](../images/Lecture05-img-12.png)

- **Precomputed texture**: Each integral produces one value for each $(roughness, \cos\theta_o)$ angle pair.



#### Results

Very fast and almost identical:

![image-20230913193333372](../images/Lecture05-img-13.png)
Loading

0 comments on commit 67a2e11

Please sign in to comment.