# Part 07 | 색상과 텍스쳐의 연산, Lerp

## 01 색상을 입력 받고, 밝기를 조절하는 기능을 만들어 봅시다

![](https://velog.velcdn.com/images/biomatrix117/post/9666ffff-350f-49a5-8eeb-316ebde12582/image.png)

RGB 컬러를 Add 노드에 입력으로 넣어주면 나머지 입력에 Brightness 값 하나만 넣어줘도 알아서 세 곳에 더해준다

RGB 값이 1을 넘어가 포스트 프로세싱 효과가 적용되는 일을 막으려면, Saturate 노드를 이용해서 값을 0\~1 사이로 제한해줄 수 있다. 최소최댓값을 직접 적용하려면 Clamp 노드를 사용할 수도 있다.

더하면 밝아지고, 곱하면 어두워지고, 나누면 밝아진다. (0\~1 값 기준) Add의 밝기 조절 범위를 ~~0~~1에서 -1\~1로 만들어주면 밝게 뿐만 아니라 어둡게도 할 수 있다.

## 02 텍스쳐를 출력해 봅시다

![](https://velog.velcdn.com/images/biomatrix117/post/f844c752-4a99-4164-bf93-6d9617048ece/image.png)

Texture 2D Asset으로 프로퍼티를 만들어준 후에, Sample Texture 2D 노드에 연결해줘야 한다. Sample Texture 2D만으로는 프로퍼티를 못 만듦. UV 노드를 연결해줄 수도 있지만, 기본적으로 0번 채널이 들어가있다.

텍스처 Tiling과 Offset을 조절하려면 Graph Inspector > Node Settings > Use Tiling and Offset 체크

## 03 이미지를 흑백으로 만들어 봅시다

![](https://velog.velcdn.com/images/biomatrix117/post/b56622a0-66aa-44ec-8c3b-0914753d8e82/image.png)

흑백(Grayscale)은 컬러가 없는 상태, 즉 RGB의 숫자가 동일한 상태.

RGB 각각의 채널을 모두 Add한 후 Divide로 나눠주면 흑백이 된다. 이 방법도 좋고 빠르긴 하지만, 정확도와는 거리가 멀다.

RGB의 밝기(휘도)는 우리 눈에 밝게 인식되는 강도가 각각 다르기 때문. 녹색 > 빨강 > 파란 순으로 밝아 보인다. (녹색이 가장 밝아 보임)

![](https://velog.velcdn.com/images/biomatrix117/post/30a8597c-0b6e-4aaf-ab4a-d9fec07cfff2/image.png)

휘도 비율을 RGB에 각각 곱한 후 더해주면 더 정확할 것이다. 직접 Multiply 노드를 추가해줄 수도 있겠지만, Saturation 노드를 추가한 후 Saturation 값을 0으로 만들어주면 휘도 차이 별 강도가 적용된 흑백을 만들 수 있다. (Saturate 노드와는 다르다)

Saturation에 프로퍼티를 적용하면 외부에서 채도를 조절하는 기능도 구현할 수 있다.

![](https://velog.velcdn.com/images/biomatrix117/post/65daa61a-f97f-44b0-88a2-b9be3c23b788/image.png)

노드별 적용 예시

## 04 Lerp 노드를 사용해 봅시다

![](https://velog.velcdn.com/images/biomatrix117/post/e7189d61-0fab-4330-a774-4792724f4635/image.png)

Lerp : Linear Interpolation, 선형 보간 한쪽이 0이고 다른 한쪽이 1이라면, 가운데는 0.5가 된다

T가 0이면 A 이미지만 나오고, 1이면 B 이미지만 나온다. Lerp는 두 이미지를 자연스럽게 전환하는데 유리하다.

## 05 Lerp 노드를 응용해 봅시다

![](https://velog.velcdn.com/images/biomatrix117/post/44d72842-d88d-4ca8-bdb4-554865a44fcf/image.png)

알파 채널이 있는 이미지와 Lerp 노드를 활용하면 이미지를 적절하게 합성할 수 있다.

![](https://velog.velcdn.com/images/biomatrix117/post/cb910745-7cc8-4a18-ace3-2a7ccbd0e198/image.png)

알파채널의 색은 숫자이고, 검은 부분은 0이니 A 텍스쳐가 나오고, 흰 부분은 1이니 B 텍스쳐가 나온다. 회색의 알파 채널이 있었다면 반반 섞였을 것이다.

Tiling and Offset과 함께 사용하면 벽이나 바닥에 새겨진 자국이나 마크 등을 그릴 수 있다.


---

# 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-07-or-lerp.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.
