기본적으로 GPU는 모든 채널(RGBA)에 작성합니다. 일부 효과의 경우 일부 채널을 수정하지 않은 상태로 두는 것이 좋습니다. 예를 들어, 컬러 렌더링을 비활성화하여 채색되지 않은 그림자를 렌더링할 수 있습니다. 이러한 커맨드가 자주 사용되는 또 다른 활용 사례는 다른 버퍼에 작성하지 않고도 데이터로 하나의 버퍼를 채울 수 있도록 컬러 작성을 완전히 비활성화하는 것입니다(예: 렌더 타겟에 작성하지 않고도 스텐실 버퍼 채우기).
Shader "Examples/CommandExample"
{
SubShader
{
// The rest of the code that defines the SubShader goes here.
Pass
{
// Enable writing only to the RGB channels for this Pass, which disables writing to the alpha channel
ColorMask RGB
// The rest of the code that defines the Pass goes here.
}
}
}
이 예제 코드는 SubShader 블록에서 이 커맨드를 사용하기 위한 구문을 나타냅니다.
Shader "Examples/CommandExample"
{
SubShader
{
// Enable writing only to the RGB channels for this SubShader, which disables writing to the alpha channel
ColorMask RGB
// The rest of the code that defines the SubShader goes here.
Pass
{
// The rest of the code that defines the Pass goes here.
}
}
}