# Part 12 | Digital Light 이론

## 01 디지털 라이트의 분류

컴퓨터 그래픽 라이트 기본 3가지 종류

* Directional Light : 조명 강도, 칼라와 '방향'밖에 없는 조명. 시작점도 끝점도 없다.
* Point Light : 사방으로 뻗어나가는 조명. 성능에 신경써서 작업해야함.
* Spot Light : 특정한 부분을 강조할 때 사용하는 조명.

## 02 디지털 라이트의 원리

조명의 방향 벡터와 물체의 노말 벡터(법선 벡터)가 서로 마주보고 있을 때 그 면은 가장 밝다.

## 04 벡터의 특성

숫자로 색상, 위치, 방향을 표현할 수 있다.

Vector3(1,0,0)은 빨강으로도, X축 방향 길이 1인 화살표로도 표현될 수 있다.\
Vector3(0,1,0)은 녹색으로도, Y축 방향 길이 1인 화살표로도 표현될 수 있다.\
Vector3(0,0,1)은 파랑으로도, Z축 방향 길이 1인 화살표로도 표현될 수 있다.

Normal Map의 RGB 칼라도 같은 느낌으로 보면 된다.

## 05 노말 벡터 (Normal Vector)

노말 벡터와 라이트 벡터가 서로 마주보면 가장 밝고, 각도가 벌어지면 점점 어두워지는데,\
노말 벡터가 면에 있으면 부드러운 라이팅을 구현할 수 없으므로,\
요즘에는 **노말 벡터가 버텍스에 있다. 버텍스 사이의 밝기 값은 보간으로 표현한다.**

그런데 보간을 해버리면 각지게 표현할 때 버텍스 주변에 있는 면들이 모두 다른 밝기를 가질 수가 없다.\
그래서 요즘의 게임 엔진은 각진 물체를 표현하기 위해 버텍스를 복사해서 같은 자리에 추가하여 표현한다.\
즉, **각지게 표현하면 요즘엔 버텍스 양이 오히려 늘어난다.**

## 07 벡터 연산을 이용한 디지털 조명 연산

가장 밝은데 -1이면 곤란하니까 연산하기 전에 조명 벡터 방향을 반대로 해준다.\
(유니티에선 조명 벡터가 뒤집힌 채로 받아오기 때문에 안 뒤집어줘도 된다)

램버트 (Lambert) 라이팅 : 조명 벡터랑 노말 벡터 내적. Diffuse Light를 표현하는 가장 흔한 방식.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lazyartisan.gitbook.io/note/main-page/books/urp/part-12-or-digital-light.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
