컬러 채널 작성 마스크를 설정하여 GPU가 렌더 타겟의 채널에 작성하지 못하게 합니다.
기본적으로 GPU는 모든 채널(RGBA)에 작성합니다. 일부 효과의 경우 일부 채널을 수정하지 않은 상태로 두는 것이 좋습니다. 예를 들어, 컬러 렌더링을 비활성화하여 채색되지 않은 섀도우를 렌더링할 수 있습니다. 이러한 커맨드가 자주 사용되는 또 다른 사용 사례는 다른 버퍼에 작성하지 않고도 하나의 버퍼를 채울 수 있도록 컬러 작성을 완전히 비활성화하는 것입니다(예: 렌더 타겟에 작성하지 않고도 스텐실 버퍼 채우기).
기능 이름 | 빌트인 렌더 파이프라인 | 유니버설 렌더 파이프라인(URP) | 고해상도 렌더 파이프라인(HDRP) | 커스텀 SRP |
---|---|---|---|---|
ColorMask | 지원 | 지원 | 지원 | 지원 |
이 커맨드는 렌더 상태를 변경합니다. Pass
블록에서 사용하여 해당 패스의 렌더 상태를 설정하거나, SubShader
블록에서 사용하여 해당 서브셰이더에 있는 모든 패스의 렌더 상태를 설정할 수 있습니다.
서명 | 예제 구문 | 기능 |
---|---|---|
ColorMask <channels> |
ColorMask RGB |
기본 렌더 타겟의 특정 채널로 작성합니다. |
ColorMask <channels> <render target> |
ColorMask RGB 2 |
특정 렌더 타겟에 한하여 위와 동일합니다. |
파라미터 | 값 | 기능 |
---|---|---|
render target | 07의 정수. | 렌더 타겟 인덱스입니다. |
channels | 0 |
R, G, B, A 채널로의 컬러 작성을 활성화합니다. |
R |
빨간색 채널로의 컬러 작성을 활성화합니다. | |
G |
초록색 채널로의 컬러 작성을 활성화합니다. | |
B |
파란색 채널로의 컬러 작성을 활성화합니다. | |
A |
알파 채널로의 컬러 작성을 활성화합니다. | |
공백 없는 R , G , B , A 의 모든 조합. 예: RB
|
특정 채널로의 컬러 작성을 활성화합니다. |
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.
}
}
}
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.