Illumination and Shading RenderingThe process of creating realistic

  • Slides: 47
Download presentation
第八章 Illumination and Shading(照明與遮蔽) Rendering:The process of creating realistic graphic scenes from geometric data.

第八章 Illumination and Shading(照明與遮蔽) Rendering:The process of creating realistic graphic scenes from geometric data. (看起來像真實物體) Illumination Models:determining a surface’s color at a given point. 也可稱為 Shading Models. 1

V: Viewing Direction N: Normal Vector of Surface S: Direction of Light Source 2

V: Viewing Direction N: Normal Vector of Surface S: Direction of Light Source 2

Object:Absorb(吸收) L Reflect(反射) Transmit(穿透) Light emitting source發光體源 Light reflecting source反射光源 3

Object:Absorb(吸收) L Reflect(反射) Transmit(穿透) Light emitting source發光體源 Light reflecting source反射光源 3

Light sources (Sx, Sy, Sz) s 點光源 1. Point source N 2. Distributed source

Light sources (Sx, Sy, Sz) s 點光源 1. Point source N 2. Distributed source 分佈、分散的光源 { 平行方向 亂射方向 4

Ambient Light(周圍的光線) 特性:⊙uniform illumination ⊙nondirectional source沒有方向性 (四面八方過來的光線) ⊙multiple reflections from nearby surfaces 由於附近的其他物體面,反射而造成。 一種無方向性,充滿在周圍的光源。

Ambient Light(周圍的光線) 特性:⊙uniform illumination ⊙nondirectional source沒有方向性 (四面八方過來的光線) ⊙multiple reflections from nearby surfaces 由於附近的其他物體面,反射而造成。 一種無方向性,充滿在周圍的光源。 5

Illumination Equation I:物體面上某一點的Intensity(亮度) Ia:Ambient light 的 Intensity (constant for all objects) ka: Ambient-reflection coefficient

Illumination Equation I:物體面上某一點的Intensity(亮度) Ia:Ambient light 的 Intensity (constant for all objects) ka: Ambient-reflection coefficient (material property物體性質) (0~1) 6

Diffuse Reflection(漫反射、散反射) (Lambertian Reflection柔和光亮的反射) ⊙在粗糙表面上。 ⊙物體面從所有方向看都一樣。 ⊙一點的亮度由 角決定 角:angle between Light Source Direction and

Diffuse Reflection(漫反射、散反射) (Lambertian Reflection柔和光亮的反射) ⊙在粗糙表面上。 ⊙物體面從所有方向看都一樣。 ⊙一點的亮度由 角決定 角:angle between Light Source Direction and Surface Normal 7

N:Surface Normal L:Direction of Light source :angle between N and L 8

N:Surface Normal L:Direction of Light source :angle between N and L 8

Diffuse Reflection(光線在物體法向量方向的分量) I:物體面上一點的Intensity(亮度) Ip:Intensity of point light source Kd:Material’s diffuse-reflection coefficient 每種材質不同(0~1) 完全吸光線 =

Diffuse Reflection(光線在物體法向量方向的分量) I:物體面上一點的Intensity(亮度) Ip:Intensity of point light source Kd:Material’s diffuse-reflection coefficient 每種材質不同(0~1) 完全吸光線 = 0 :angle between and :Surface Normal(unit vector) :Light Source Direction(unit vector) 9

11

11

Ambient Light + Diffuse Reflection 合成 2光源 合成 Ambient Diffuse Reflection 12

Ambient Light + Diffuse Reflection 合成 2光源 合成 Ambient Diffuse Reflection 12

計算一個 Surface 上各點Pixel的亮度 1. Surface 定義 → Pixels 2. 計算每一個 pixel 點位置,在幾何上的Surface Normal 3.

計算一個 Surface 上各點Pixel的亮度 1. Surface 定義 → Pixels 2. 計算每一個 pixel 點位置,在幾何上的Surface Normal 3. 決定 Light Source 4. 計算各點 5. 找到 Surface 的 Kd(與材質有關) 6. 決定 IP(intensity and scolor) 7. 決定 I(intensity and color) 13

Light – Source Attenuation factor fatt:attenuation factor 由 Light source 及 surface 之間距離決定。 15

Light – Source Attenuation factor fatt:attenuation factor 由 Light source 及 surface 之間距離決定。 15

較複雜的表示法 User defined constant C 1:當很近時,fatt 不致太大。 Max = 1,fatt 最大 = 1 17

較複雜的表示法 User defined constant C 1:當很近時,fatt 不致太大。 Max = 1,fatt 最大 = 1 17

Colored Lights and Surfaces 在一個 color model 中每一個 component 都 是一個 Intensity Equation。 Diffuse

Colored Lights and Surfaces 在一個 color model 中每一個 component 都 是一個 Intensity Equation。 Diffuse Color(Od. R,Od. G,Od. B)材質色 red green blue Illuminating Light(Ip. R,Ip. G,Ip. B)燈光色 red green blue Reflection 比例(Kd. Od. R,Kd,Od. G,Kd. Od. B) 18

元素分別計算再合成 (1)Red Component (2)Gree Component (3)Blue Component 19

元素分別計算再合成 (1)Red Component (2)Gree Component (3)Blue Component 19

Specular Reflection(鏡反射) ⊙在光亮表面上(如金屬表面) ⊙鏡子是一個 perfect specular reflection 20

Specular Reflection(鏡反射) ⊙在光亮表面上(如金屬表面) ⊙鏡子是一個 perfect specular reflection 20

Phong Model(specular reflection) 1. 最大 specular reflection 發生在 2. 當 3. 由 增加,specular reflection

Phong Model(specular reflection) 1. 最大 specular reflection 發生在 2. 當 3. 由 增加,specular reflection 急速減小 決定 specular reflection n:type of surface 很亮: 100 灰暗: 1(粉筆) 21

Direction of Reflection(unit vector) View Direction(unit vector) Angle between Ambient and Diffuse Specular Reflection

Direction of Reflection(unit vector) View Direction(unit vector) Angle between Ambient and Diffuse Specular Reflection 22

已知 , , ,求 Projection of onto → 23

已知 , , ,求 Projection of onto → 23

Phong 的 Specular Reflection Model 決定 specular reflection 大小 中以 Angle between and n

Phong 的 Specular Reflection Model 決定 specular reflection 大小 中以 Angle between and n = 1 to hundred 當n = 時,為 perfect specular n意義:n = 1時,是 broad gentle fall-off n較高時是 sharp focused highlight 24

Phong Model式子 Ambient W Diffuse Specular Reflection :Surface material specular reflection coefficient silver gold

Phong Model式子 Ambient W Diffuse Specular Reflection :Surface material specular reflection coefficient silver gold 與材質有關的常數 glass 設為一常數 Ks 25

Transparency Transparent surface:透明的面 Both reflection and transmitted light (reflection) ( Transmission ) 26

Transparency Transparent surface:透明的面 Both reflection and transmitted light (reflection) ( Transmission ) 26

Snell’s Law: :angle of reflection :物體性質 T:Transmission vector → 27

Snell’s Law: :angle of reflection :物體性質 T:Transmission vector → 27

透明 Kt=1 I:Total surface Intensity Kt:transparency coefficient (0~1) (1 -Kt): opacity factor (不透明) Iref:reflected

透明 Kt=1 I:Total surface Intensity Kt:transparency coefficient (0~1) (1 -Kt): opacity factor (不透明) Iref:reflected intensity Itran:transmitted intensity 28

Shading Models for Polygons 計算及得到物體每一 面中每一pixel的亮度 值,以表現立體感觀。 以Interpolation得到一面中之pixels,不需計算每一pixel。 以polygonal planar surfaces為主。 Curved surface需經apprximation成為 polygonal

Shading Models for Polygons 計算及得到物體每一 面中每一pixel的亮度 值,以表現立體感觀。 以Interpolation得到一面中之pixels,不需計算每一pixel。 以polygonal planar surfaces為主。 Curved surface需經apprximation成為 polygonal planar surface。 29

Shading Models for Polygons (cont. ) 方法: 1. Constant Shading 2. Interpolated Shading 3.

Shading Models for Polygons (cont. ) 方法: 1. Constant Shading 2. Interpolated Shading 3. Gouraud Shading 4. Phong Shading 30

Shading Models for Polygons (cont. ) 1. Constant Shading (faceted shading、flat shading) 方法:(1) sample

Shading Models for Polygons (cont. ) 1. Constant Shading (faceted shading、flat shading) 方法:(1) sample one pixel (2) use a single intensity to shade an entire polygon 需符合以下情形,才能使用constant shading (1)Light source is is constant across polygon (2)Viewer is at is constant across polygon (3)Planar Surface only 31

Shading Models for Polygons (cont. ) 2. Interpolated Shading information is linearly interpolated across

Shading Models for Polygons (cont. ) 2. Interpolated Shading information is linearly interpolated across a polygon from values of vertices 從面的端點之亮度作線性內差,以得到面 上一點之亮度 32

Shading Models for Polygons (cont. ) Polygon Mesh Shading (1)Approximation a curved surface by

Shading Models for Polygons (cont. ) Polygon Mesh Shading (1)Approximation a curved surface by a polygonal mesh (2)Each polygonal facet in the mesh is shaded individually 3. Gouraud Shading 也稱作intensity interpolation shading 使用average vertex normal來計算 average intensity for each vertex 33

Polygon Mesh Shading (cont. ) 3. Gouraud Shading (cont. ) 方法: 1. 計算每一vertex的average intensity

Polygon Mesh Shading (cont. ) 3. Gouraud Shading (cont. ) 方法: 1. 計算每一vertex的average intensity (1)處理一端點vertex (2)找到交於vertex 的所有surfaces (3)算出所有Surfaces的Normals (4)算出 vertex normal 為各Surface Normals的平均 34

Polygon Mesh Shading (cont. ) 3. Gouraud Shading (cont. ) vertex normal 35

Polygon Mesh Shading (cont. ) 3. Gouraud Shading (cont. ) vertex normal 35

3. Gouraud Shading (cont. ) 2. 用 Illumination Model 算出 vertex intensity 利用vertex Normal算出端點亮度

3. Gouraud Shading (cont. ) 2. 用 Illumination Model 算出 vertex intensity 利用vertex Normal算出端點亮度 (包含所有亮度) 3. Each polygon is shaded by linearly interpolation of vertex intensities along edges and between edges 用vertex的intensities作線性內差, 算出面上的一點intensity 36

3. Gouraud Shading (cont. ) 4. Surface 上每一 pixel 點的 intensity 都由 vertex intensity

3. Gouraud Shading (cont. ) 4. Surface 上每一 pixel 點的 intensity 都由 vertex intensity 計算 求 37

3. Gouraud Shading (cont. ) 3 1 5 6 4 2 38

3. Gouraud Shading (cont. ) 3 1 5 6 4 2 38

3. Gouraud Shading (cont. ) For a triangle Parametric equation: 其中 39

3. Gouraud Shading (cont. ) For a triangle Parametric equation: 其中 39

3. Gouraud Shading (cont. ) 其中 40

3. Gouraud Shading (cont. ) 其中 40

Shading Models for Polygons (cont. ) 4. Phong Shading(Normal-vector Interpolation Shading) 特點:interpolates the surface

Shading Models for Polygons (cont. ) 4. Phong Shading(Normal-vector Interpolation Shading) 特點:interpolates the surface normal at each point(not intensity) 方法: (1)Interpolates Normal Vectors at the polygon edges from vertex normals 從端點Normal作線 性內差得到邊線上 各點的Normal 41

4. Phong Shading(cont. ) (2)得到邊線上各點的Normal (3)Each pixel’s normal is interpolated along scan line (面上一點的normal,是由邊線上之點,

4. Phong Shading(cont. ) (2)得到邊線上各點的Normal (3)Each pixel’s normal is interpolated along scan line (面上一點的normal,是由邊線上之點, 3 1 6 4 5 沿著掃瞄線作內差而得。) N 4 from 1 , 2 N 6 from 2 , 3 N 5 from 4 , 6 利用 2 42 得

4. Phong Shahing(cont. ) (4)由面上各點的Normal計算各點的Intensity 特點: 無變 化 Constant Shading Interpolated Shading 43 平均

4. Phong Shahing(cont. ) (4)由面上各點的Normal計算各點的Intensity 特點: 無變 化 Constant Shading Interpolated Shading 43 平均 的變 化

4. Phong Shahing(cont. ) 可能失 去 highlight Gouraud Shading Phong Shading 會保留 highlight 44

4. Phong Shahing(cont. ) 可能失 去 highlight Gouraud Shading Phong Shading 會保留 highlight 44

4. Phong Shahing(cont. ) 問題點: 1. Polygonal silhouette 在作 polygonal approximation of curved surface時,

4. Phong Shahing(cont. ) 問題點: 1. Polygonal silhouette 在作 polygonal approximation of curved surface時, 會在邊線產生輪廓 2. Perspective distortion 因為interpolation是在Image Space coordinate進行, 所以與原幾何物件會有誤差 45

4. Phong Shahing(cont. ) 3. Orientation dependence 有方向性。Interpolation的方向會影響結果。 IP IP Rotation後,IP不同intersity 46

4. Phong Shahing(cont. ) 3. Orientation dependence 有方向性。Interpolation的方向會影響結果。 IP IP Rotation後,IP不同intersity 46

4. Phong Shahing(cont. ) 4. Shared vertices 從左看:C from A , B 從右看:C 是單獨

4. Phong Shahing(cont. ) 4. Shared vertices 從左看:C from A , B 從右看:C 是單獨 vertex A C B 5. Unrepresentative vertex normals Parallel Normals 若 Normals 都平行 ,不足以代表面的真實情況 47