Presentation is loading. Please wait.

Presentation is loading. Please wait.

第八章 Illumination and Shading

Similar presentations


Presentation on theme: "第八章 Illumination and Shading"— Presentation transcript:

1 第八章 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.

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

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

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

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

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

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

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

9 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)

10 Lambert’s cosine Law 當光源假設為很遠時, 為固定方向。 →各點的 影響各點的亮度。

11

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

13 計算一個 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)

14 Light – Source Attenuation(光線變淡)--衰減
為了分出遠近,光線越遠應越淡。 物面上的亮度,越遠應越暗。 若相同 intensity 則無法分出遠近。 較遠者,其 intensity 應較暗才能分出遠近。

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

16 Attenuation Factor dL:point Light Source 與 Surface 之間的距離。 但是 ,很近時變化很大。 ,很遠時變化很小。

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

18 Colored Lights and Surfaces
在一個 color model 中每一個 component 都是一個 Intensity Equation。 Diffuse Color(OdR,OdG,OdB)材質色 red green blue Illuminating Light(IpR,IpG,IpB)燈光色 red green blue Reflection 比例(KdOdR,Kd,OdG,KdOdB)

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

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

21 Phong Model(specular reflection)
n:type of surface 很亮:100 灰暗:1(粉筆)

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

23 已知 , , ,求 Projection of onto

24 當n = 時,為 perfect specular
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

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

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

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

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

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

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

31 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

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

33 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

34 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的平均

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

36 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

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

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

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

40 3. Gouraud Shading (cont.)
其中

41 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

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

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

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

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

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

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


Download ppt "第八章 Illumination and Shading"

Similar presentations


Ads by Google