GPU가 프래그먼트 셰이더의 출력을 렌더 타겟과 조합하는 방식을 결정합니다.
이 커맨드의 기능은 블렌딩 작업에 따라 달라집니다. 블렌딩 작업은 BlendOp 커맨드를 사용하여 설정할 수 있습니다. 블렌딩 자체는 모든 그래픽스 API와 하드웨어에서 지원되지만, 일부 블렌딩 작업은 보다 제한적으로 지원됩니다.
블렌딩을 활성화하면 GPU의 일부 최적화(주로 숨겨진 표면 제거/Early-Z)가 비활성화되어 GPU 프레임 시간이 늘어날 수 있습니다.
기능 이름 | 빌트인 렌더 파이프라인 | 유니버설 렌더 파이프라인(URP) | 고해상도 렌더 파이프라인(HDRP) | 커스텀 SRP |
---|---|---|---|---|
Blend | 지원 | 지원 | 지원 | 지원 |
이 커맨드는 렌더 상태를 변경합니다. Pass
블록에서 사용하여 해당 패스의 렌더 상태를 설정하거나, SubShader
블록에서 사용하여 해당 서브셰이더에 있는 모든 패스의 렌더 상태를 설정할 수 있습니다.
블렌딩이 활성화되면 다음과 같은 일이 발생합니다.
Add
로 설정됩니다.Add
, Sub
, RevSub
, Min
또는 Max
이면 GPU가 프래그먼트 셰이더의 출력값과 소스 인자를 곱합니다.Add
, Sub
, RevSub
, Min
또는 Max
이면 GPU가 이미 렌더 타겟에 있는 값과 대상 인자를 곱합니다.블렌딩 등식은 다음과 같습니다.
finalValue = sourceFactor * sourceValue operation destinationFactor * destinationValue
이 등식에서:
finalValue
는 GPU가 대상 버퍼에 작성하는 값입니다.sourceFactor
는 Blend 커맨드에 정의되어 있습니다.sourceValue
는 프래그먼트 셰이더에 의한 값 출력입니다.operation
은 블렌딩 작업입니다.destinationFactor
는 Blend 커맨드에 정의되어 있습니다.destinationValue
는 이미 대상 버퍼에 있는 값입니다.서명 | 예제 구문 | 기능 |
---|---|---|
Blend <state> |
Blend Off |
기본 렌더 타겟의 블렌딩을 비활성화합니다(기본값). |
Blend <render target> <state> |
Blend 1 Off |
특정 렌더 타겟에 한하여 위와 동일합니다. (1) |
Blend <source factor> <destination factor> |
Blend One Zero |
기본 렌더 타겟의 블렌딩을 활성화합니다. RGBA 값의 블렌드 인자를 설정합니다. |
Blend <render target> <source factor> <destination factor> |
Blend 1 One Zero |
특정 렌더 타겟에 한하여 위와 동일합니다. (1) |
Blend <source factor RGB> <destination factor RGB>, <source factor alpha> <destination factor alpha> |
Blend One Zero, Zero One |
기본 렌더 타겟의 블렌딩을 활성화합니다. RGB 값과 알파값의 블렌드 인자를 별도로 설정합니다. (2) |
Blend <render target> <source factor RGB> <destination factor RGB>, <source factor alpha> <destination factor alpha> |
Blend 1 One Zero, Zero One |
특정 렌더 타겟에 한하여 위와 동일합니다. (1) (2) |
참고:
GL_ARB_draw_buffers_blend
또는 OpenGL ES 3.2가 필수입니다.파라미터 | 값 | 기능 |
---|---|---|
render target | 07 범위의 정수 | 렌더 타겟 인덱스입니다. |
state | Off |
블렌딩을 비활성화합니다. |
factor | One |
이 입력의 값은 1입니다. 소스 또는 대상 컬러의 값을 사용하려면 이 값을 사용합니다. |
Zero |
이 입력의 값은 0입니다. 소스 또는 대상 값을 제거하려면 이 값을 사용합니다. | |
SrcColor |
GPU는 이 입력의 값과 소스 컬러값을 곱합니다. | |
SrcAlpha |
GPU는 이 입력의 값과 소스 알파값을 곱합니다. | |
DstColor |
GPU는 이 입력의 값과 프레임 버퍼 소스 컬러값을 곱합니다. | |
DstAlpha |
GPU는 이 입력의 값과 프레임 버퍼 소스 알파값을 곱합니다. | |
OneMinusSrcColor |
GPU는 이 입력의 값과 (1 - 소스 컬러)를 곱합니다. | |
OneMinusSrcAlpha |
GPU는 이 입력의 값과 (1 - 소스 알파)를 곱합니다. | |
OneMinusDstColor |
GPU는 이 입력의 값과 (1 - 대상 컬러)를 곱합니다. | |
OneMinusDstAlpha |
GPU는 이 입력의 값과 (1 - 대상 알파)를 곱합니다. |
다음은 대다수의 일반적인 블렌드 타입을 위한 구문입니다.
Blend SrcAlpha OneMinusSrcAlpha // Traditional transparency
Blend One OneMinusSrcAlpha // Premultiplied transparency
Blend One One // Additive
Blend OneMinusDstColor One // Soft additive
Blend DstColor Zero // Multiplicative
Blend DstColor SrcColor // 2x multiplicative
Shader "Examples/CommandExample"
{
SubShader
{
// The rest of the code that defines the SubShader goes here.
Pass
{
// Enable regular alpha blending for this Pass
Blend SrcAlpha OneMinusSrcAlpha
// The rest of the code that defines the Pass goes here.
}
}
}
이 예제 코드는 SubShader 블록에서 이 커맨드를 사용하기 위한 구문을 나타냅니다.
Shader "Examples/CommandExample"
{
SubShader
{
// Enable regular alpha blending for this SubShader
Blend SrcAlpha OneMinusSrcAlpha
// The rest of the code that defines the SubShader goes here.
Pass
{
// The rest of the code that defines the Pass goes here.
}
}
}
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.