Games101 筆記 Lecture 7-9 Shading [Shading Frequencies 着色頻率]
- Shading Frequencies 着色頻率
-
- Flat Shading
- Gouraud Shading
- Phong Shading
- Defining Per-Vertex Normal Vectors
- Defining Per-Pixel Normal Vectors
Shading Frequencies 着色頻率
着色頻率實際是指将着色應用在哪些點上。
Flat Shading
- Flat Shading: 每一個三角形都是一個平面,把三角形的法線求出來,算出一個shading的結果作為着色的結果。
- shade each triangle
- Triangle faces is flat - one normal vector
- Not good for smooth surfaces
Gouraud Shading
- Gouraud Shading: 在任意一個頂點上求出法線,每個頂點做一次着色,三角形内部通過插值的方法求出來。
- shade each vertex
- Interpolate colors from vertices across triangle
- Each vertex has a normal vector
Phong Shading
- Phong Shading: 求出三角形三個頂點的法線,在三角形内部每個像素上都可以插值得到一個獨特的法線,就可以對每一個像素進行着色。(與Blinn_Phong Reflectance Model無關)
- shade each pixel
- Interpolate normal vectors across each triangle
- Compute full shading model at each pixel
效果不僅與頻率相關,還與幾何形體本身的頂點密集程度相關。
當幾何足夠複雜時,可以用一些稍微簡單的着色頻率。
着色頻率的複雜度也取決于幾何形體。
對于一般物體,Phong shading會有比較好的效果。
Defining Per-Vertex Normal Vectors
-
Best to get vertex normals from the underlying geometry
一個理想化的情況,已知試圖表示的幾何體結構,可以利用該幾何結構計算出某點對應的法線。
-
Otherwise have to infer vertex normals from triangle faces
任何一個頂點都會與若幹個三角形産生關聯,該頂點的法線認為是相鄰的幾個面法線方向的平均。
改進:做權重平均,權值為對應三角形的面積。
N v = ∑ i N i ∥ ∑ i N i ∥ N_v=\frac {\sum_{i}N_i} {\lVert \sum_{i}N_i\rVert} Nv=∥∑iNi∥∑iNi
Defining Per-Pixel Normal Vectors
Barycentric interpolation of vertex normals
已知頂點的法線,如何得到其内部某一點對應的法線?
求出的法線記得歸一化處理。