본문 바로가기
Computer Science/Computer Graphics

Lighting

by Gofo 2021. 5. 31.

Reflection of Light

Ligth

빛은 물체에 의해 다음과 같이 될 수 있다.

  • absorbed : 흡수
  • emitted : 발산
  • scattered : 산란
  • reflected : 반사
  • refracted : 굴절

 

그 중 scaterring(산란)과 reflection(반산)이 물체의 표면의 시각적인 모습을 결정하는 결정적인 요인이다.

물체의 색상, highlight 등을 결정한다.

scaterring과 reflection을 합쳐서 reflection이라고도 한다.

 

Reflection

Reflection은 다음과 같이 구분된다.

  • Diffuse reflection
    • 난반사
    • 모든 방향으로 빛이 반사된다.
  • Specular reflection
    •  정반사
    • ideal specular reflection
      • 완전히 한쪽 방향으로 반사된다.
    • non-ideal specular reflection (glossy reflection)
      • 한쪽 방향으로 빛이 퍼지면서 반사된다.

 


Diffuse Reflection (난반사)

표면에 빛이 들어올 때 사방으로 동일한 정도로 빛이 퍼지는(산란되는) 것을 말한다.

거울같이 완전히 매끄러운 표면이 아닐 경우 모든 물체에 diffuse reflection이 있다.

 

  • diffuse reflection은 표면의 색상을 결정
    • 퍼지는 빛의 파장에 의해 물체의 색상이 결정된다.
  • view-independent
    • 모든 같은 정도로 빛이 퍼지기 때문에 어디서 보든 색상이 동일하다.
  • Lambert's cosine law를 따른다.

 

Lambert's Cosine Law

"어떤 물체의 표면에서 반사되는 빛의 크기는 입사광과 normal 사이의 각도의 cos 값에 비례한다."

 

$I_{reflected} = I_{incident} cos \theta = I_{incident} (\hat{N} \cdot \hat{L})$

 

 

동일한 크기로 빛이 반사되지만, 그 크기는 들어오는 빛의 각도에 따라서 달라진다.

normal과 평행하게 빛이 들어온다면 반사되는 빛의 크기가 가장 크고, normal과 수직으로 들어오면 반사되는 빛의 크기는 0이다.

 


Ideal Specular Reflection

매우 매끄러운 표면에서 일어나는 reflection이다.

거울과 같은 이미지를 만들어낸다.

 

빛이 한 방향으로 퍼지기 때문에 view-dependent이다.

보는 각도에 따라서 보여지는 모습이 다르다.

 

Law of reflection을 따른다.

 

Law of Reflection (반사의 법칙)

"입사각과 반사각이 같다."

 

$\theta _r = \theta _i$

* $\hat{L}, \hat{L}, \hat{R}$은 모두 같은 평면에 놓여있다.

 

 


Non-Ideal Specular Reflection (Glossy Reflection)

이상적으로 완전히 한 방향으로만 반사하지는 않고, 주변으로 빛이 약간 퍼진다.

거울같이 매우 매끄럽지는 않고, 약간 매끄러운 표면에서 일어난다.

 

반사광이 퍼지는 정도는 표면의 roughness에 따라 달라진다.

매끄러운 정도가 높으면 퍼지는 방향이 좁아지고, 그렇지 않으면 넓어진다.

 

Bright highlight를 만들어낸다.

모든 방향으로 동일하게 퍼지지 않기 때문에 view-dependent 이다.

 

 


일반적인 물체

일반적인 물체는 diffuse reflection과 specular reflection을 모두 가지고 있다.

빛의 크기와 퍼지는 정도는 물체마다 다르다.

 

 

 


Phong Illumination Model

Illumination (Lighting)

빛의 효과를 계산하는 과정이다.

  • surface color
  • highlights of object

 

Phong Illumination Model

가장 유명한 illumination model이다.

Empirical model로, 물리적으로 사실적이지는 않다.

 

3가지 component로 구성되어있다.

  • Ambient
    • non-specific constant global lighting
    • indirect lighting을 대강 추정해서 표면의 모든 부분에 뿌린 것이다.
      • indirect lighting : 광원 뿐만아니라 다른 물체에서 반사된 빛까지 고려한 것
    • 물체의 모든 부분에서 동일하게 아주 약한 정도로 빛이 나온다고 생각한다.
    • 이를 통해 물체의 뒷부분(빛이 없는 부분)도 약하게 볼 수 있다.
  • Diffuse
    • Lambert 법칙을 사용해서 normal condition에 있는 물체의 색을 결정한다.
  • Specular
    • 물체의 highlihgts 만을 결정한다.
    • 반사된 빛이 퍼지는 정도를 결정하기 위해서 $cos^n(\alpha)$가 붙는다.
      • n의 크기를 결정함으로써 퍼지는 정도가 좁은지 큰지를 결정할 수 있다.

 

Ambient Light

$I = k_a C_a$

$C_a$ : ambient light의 intensity ($C_{a}^r, C_{a}^g, C_{a}^b$)

$k_a$ : ambient reflection coefficient(계수)

 

coefficient는 디자이너가 마음에 드는대로 조절한다.

실제 식은 red, green, blue에 대해서 각각 존재한다. ($C_{a}^r, C_{a}^g, C_{a}^b$)

 

Ambient light는 위치와 관계 없이 물체 표면 어디에서나 동일하게 나온다.

 

  • ambient reflection coefficient  → 물체의 색이 더 잘 나타남
  • ambient reflection coefficient ↓ → 물체가 어두워짐

 

Diffuse Light

$I = C_d k_d cos(\theta) = C_d k_d (L \cdot N)$

$C_d$ : light source의 intensity (r, g, b에 대해 각각 존재)

$k_d$ : diffuse reflection coefficient 

$\theta$ : normal과 입사광 사이의 각도

 

Ambient light에 diffuse light를 적용한 결과는 오른쪽과 같다.

highlight가 없는 무광 재질처럼 보인다.

 

  • diffuse reflection coefficient ↑ → 물체의 색이 더 잘 나타남
  • diffuse reflection coefficient ↓ → 물체의 색 나타나지 않음 (어두워짐)

 

 

Specular Light

$I = C_s k_s cos^n(\alpha) = C_s k_s (R \cdot E)^n$

$C_s$ : light source의 intensity (r, g, b에 대해 각각 존재)

$k_s$ : specular reflection coefficient

$\alpha$ : 반사광(R)과 눈(E) 사이의 각도

$n$ : shininess coefficient

 

cos을 통해서 glossy reflection(non-ideal specular reflection)에 대해서 추정값을 나타낸다.

$\alpha$를 통해서 반사각에서 눈이 멀어질 수록 highlight가 작아짐을 나타낸다.

n이 커질수록 highlight가 더 작아져서 표면이 더 매끄럽게 된다.

 

  • shininess coefficient ↑ / $\alpha$ ↑ / specular reflection coefficient ↓ → highlight ↓
  • shininess coefficient ↓ / $\alpha$ ↓ / specular reflection coefficient ↑ → highlight ↑

 

Total Illumination

$I = k_a C_a + k_d C_d (L \cdot N) + k_s C_s (R \cdot E) ^n$

 

ambient, diffuse, specular를 합해서 전체 illumination을 나타내면 다음과 같이 된다.

 


참고

본 포스트는 한양대학교 이윤상 교수님의 수업을 정리한 내용입니다.

출처: 한양대학교 이윤상 교수님 컴퓨터그래픽스 강의 강의자료 - https://cgrhyu.github.io/courses/2022-spring-cg.html

 

CGR LAB

Computer Graphics - 2022 Spring Instructor: Yoonsang Lee Teaching Assistant: Chaejun Sohn Undergraduate Mentor: Bokyoung Jang Time / Location: Mon 09:00-11:00 / Online (originally 207 IT.BT Building) - Lab Wed 09:00-11:00 / 508 IT.BT Building - Lecture Cou

cgrhyu.github.io

 

 

Phong Illumination Online-demo

http://www.cs.toronto.edu/~jacobson/phong-demo/

 

WebGL - Phong Shading

Your browser does not support the canvas element Gouraud Shading Phong Shading Knot Cube Plane Sphere Hose Teapot normal mode ambient only diffuse only specular only Reload Shader Code Ambient reflection (ka):1.0 Ambient color:   Light position: Diffuse r

www.cs.toronto.edu

 

 

'Computer Science > Computer Graphics' 카테고리의 다른 글

[OpenGL] Lighting, Shading  (0) 2021.05.31
Shading  (0) 2021.05.31
Mesh, OBJ File  (0) 2021.04.08
Rendering Pipeline, Transformation Pipeline  (0) 2021.04.07
Affine Frame  (0) 2021.03.23

댓글