일부 #pragma
지시문은 특정 그래픽스 API와 플랫폼을 타게팅할 수 있도록 하는 파라미터를 가져옵니다. 이 페이지는 이러한 지시문을 사용하는 방법에 대한 정보를 포함하며, 유효한 파라미터 값의 리스트를 제공합니다.
기본적으로 Unity는 현재 빌드 타겟을 위한 리스트에 있는 각 그래픽스 API를 위한 모든 셰이더 프로그램을 컴파일합니다. 간혹 특정 그래픽스 API만을 위해 특정 셰이더 프로그램을 컴파일하는 것이 좋을 수 있습니다(예: 일부 플랫폼에서만 지원되는 기능을 사용하는 경우).
특정 API만을 위해 셰이더 프로그램을 컴파일하려면 #pragma only_renderers
지시문을 사용하십시오. 공백으로 구분하여 여러 개의 값을 전달할 수 있습니다.
이 예제는 Metal과 Vulkan만을 위해 셰이더를 컴파일하는 방법을 나타냅니다.
# pragma only_renderers metal vulkan
특정 컴파일러의 컴파일에서 셰이더 코드를 제외하려면 #pragma exclude_renderers
지시문을 사용하십시오. 공백으로 구분하여 여러 개의 값을 전달할 수 있습니다.
이 예제는 Metal과 Vulkan을 위한 컴파일에서 셰이더를 제외하는 방법을 나타냅니다.
# pragma exclude_renderers metal vulkan
빌트인 렌더 파이프라인에서 Unity는 특정 조건 하에서 그래픽스 티어에 상응하는 셰이더 배리언트를 자동으로 생성합니다. 필요한 경우 Unity가 이러한 배리언트를 생성하도록 강제할 수도 있습니다.
이를 수행하려면 #pragma hardware_tier_variants
프리 프로세서 지시문을 사용하고 티어 셰이더 배리언트를 생성할 그래픽스 API를 지정하십시오.
예를 들어, 다음은 Unity에게 Metal을 위한 티어 셰이더 배리언트를 컴파일하도록 명령합니다.
# pragma hardware_tier_variants metal
지원되는 값은 다음과 같습니다.
값 | 설명 |
---|---|
d3d11 |
DirectX 11 기능 레벨 10 이상, DirectX 12 |
gles |
OpenGL ES 2.0, WebGL 1.0 |
gles3 |
OpenGL ES 3.x, WebGL 2.0 |
ps4 |
PlayStation 4 |
xboxone |
Xbox One 및 GameCore, DirectX 11 및 DirectX 12 |
metal |
iOS/Mac Metal |
glcore |
OpenGL 3.x, OpenGL 4.x |
vulkan |
Vulkan |
switch |
Nintendo Switch |
ps5 |
PlayStation 5 |
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.