Blend 커맨드는 GPU가 프래그먼트 셰이더의 출력을 렌더 타겟과 조합하는 방식을 결정합니다.
이 커맨드의 기능은 BlendOp 커맨드를 사용하여 설정할 수 있는 블렌딩 작업에 따라 다릅니다. 블렌딩 자체는 모든 그래픽스 API와 하드웨어에서 지원되지만 일부 블렌딩 작업은 제한적으로 지원됩니다.
블렌딩을 활성화하면 GPU의 일부 최적화(주로 숨겨진 표면 제거/Early-Z)가 비활성화되어 GPU 프레임 시간이 늘어날 수 있습니다.
다음은 대다수의 일반적인 블렌드 유형을 위한 구문입니다.
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.
}
}
}