計算機圖形學:顏色模型、圖像基本知識、Phong光照模型

顏色模型、圖像基本知識、Phong光照模型

1.顏色模型

1.1 RGB Color Space

image

The reason why we pick red, green, and blue?

  • essentially because of the structure of our visual system
  • Our visual system is sensitive to those three colors

缺陷

Unfortunately ,Some colors cannot be written as combinations of RGB triples, because some parts of the red curve is negative

image

1.2 CMY

Cyan(青), magenta(品紅) , and yellow

It’s called subtractive primaries(減色系統)

image

1.3 HSV Color space

RGB 不是很直觀,HSV比較易於理解

  • Hue (色調) means the base color, which is a main factor indicates difference between colors.
  • Saturation(飽和度) is for purity of color (decrease = adding white)
  • Value of brightness(亮度) Luminance of lights,(decrease = adding black)

image

2.圖像基本知識

2.1 Image & Pixel

  • Image could be treated as a 2-dimensional
    discrete function f(x,y)
  • each discrete grid is called pixel

image

2.2 Triangle Mesh

image

Contains a list of faces F, and a list of vertices V

  • A list of faces F = (f1,f2,…,fn), Each face is a triangle
  • A list of vertices V = (v1,v2,…,vn), Each face in F is a list of indices in V

e.g.

f1–(v1,v2,v3 ), f2 --(v4,v5,v6 ),
f3–(v7,v8,v9 ), …

2.3 Normal

2.3.1 Face Normal

image

Each face has a normal direction to define the orientation

2.3.2 Vertex Normal

image

Each vertex is shared by m faces

計算方法
  • 直接平均:Compute normal by Interpolation Nv= (Nf1+Nf2 … + Nfm)/m
  • 面積加權平均:or by area based Interpolation Nv= (|F1|*Nf1+|F2|*Nf2 … + |Fm|*Nfm)/(|F1|+|F2|+…|Fm|)
  • 角度加權平均:or by angle based Interpolation Nv= (|A1|*Nf1+|A2|*Nf2 … + |Am|*Nfm)/(|A1|+|A2|+…|Am|)

3.光照模型

Local Lighting

  • Concerned with how objects are directly illuminated by light sources

Global Lighting

  • Includes shadow effects
  • Includes lighting effects from locations other than light sources, such as reflections, refractions

3.1 History of Lighting

  • In 1967, Wylie: first added lighting effects into rendering
    • Intensity is inverse of the distance to the light
  • In 1970, Bouknight: introduced the first lighting
    model:
    • Lambert diffuse reflection(漫發射) + ambient (No specular lighting)(環境光)
  • In 1971, Gourand: gourand shading
    • Lambert diffuse + Bicentric interpolation
  • In 1975, Phong: proposed extended the model by further considering specular:
    • Diffuse(漫發射) + ambient(環境光,模擬全局光照效果) + specular(高光)
    • The most influenced lighting model

image

3.2折射向量的計算

image

image

  • incidence_rayincidence\_ray: 入射角(單位向量)

  • normal_vecnormal\_vec = Vector(0, 0, 1) //法向量

  • refractive_indexrefractive\_index: 介質密度比(空氣/水)

cosθi=incidence_ray.dot(normal_vec)cosθr=1refractive_index2(1cosθi2)  (0)refracted_ray=(normal_veccosθi+incidence_ray)refractive_indexnormal_veccosθr \cos\theta_{i} = -incidence\_ray.dot(normal\_vec)\\ \cos \theta _{r} = \sqrt{1 - refractive\_index^{2} * (1 - {\cos \theta_{i}}^{2})}\ \ (大於0時)\\ refracted\_ray = (normal\_vec * \cos\theta_{i} + incidence\_ray) * refractive\_index - normal\_vec * \cos \theta _{r}

3.3 Measure of light

image

  • Solid Angle(立體角) :
    • How big an object appears to an observer at point P
    • Max Vaule: 4π

dw=dsr2 dw = \frac{ds}{r^2}

  • Irradiance (輝度) E
    • E defined as: light energy per unit time arrived at per unit area (ds)
  • Radiance (發光強度) I
    • I defined as: irradiance per unit solid angle

3.4 Phong Lighting Model

3.4.1 Diffuse reflection

  • 漫反射光的傳播是各向同性的(isotropic)
  • The intensity of diffuse reflection is defined as:

Id=IiKd(LN) I_d = I_iK_d*(L \cdot N)

  • kdk_dis the diffuse reflection constant (kdr,kdg,Kdb)(k_{dr},k_{dg},K_{db})
  • kdk_dimplies the base color of the model

3.4.2 Specular reflection

  • The intensity of specular reflection is defined as:

Is=IiKs(RV)n I_s = I_iK_s*(R \cdot V)^n

  • ksk_sis the specular reflection constant ;
  • and n is the shininess constant, which decides how shiny the surface is. n越大,高光越集中

image

3.4.3 Ambient reflection

  • To approximate global illuminations (including indirect lighting, indirect reflection…)
  • The intensity of ambient reflection is defined as:

Ia=IiKa I_a = I_iK_a

  • KaK_ais the ambient reflection constant

3.4.4 最終結果

The reflection intensity is the sum of diffuse reflection, specular reflection and ambient reflection:

I=IiKa+IiKs(RV)n+IiKd(LN) I = I_iK_a + I_iK_s*(R \cdot V)^n + I_iK_d*(L \cdot N)

image

3.5 Blinn-Phong Lighting Model

H=L+V2Is=IiKs(NH)n H=\frac{L+V}{2}\\ I_s = I_iK_s*(N \cdot H)^n

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章