표면 셰이더 또는 일반 셰이더 프로그램으로 작성할 때 HLSL 소스를 다른 “셰이더 모델”로 컴파일할 수 있습니다. 더 최신 GPU 기능을 사용하려면 더 높은 버전의 셰이더 컴파일 타겟을 사용해야 합니다.
참고: 더 높은 버전의 셰이더 컴파일 타겟을 사용하면 셰이더가 구형 GPU 또는 플랫폼에서 작동하는 것을 막을 수 있습니다.
#pragma target
name 지시문 또는 더욱 구체적인 #pragma require
feature … 지시문을 사용하여 컴파일 타겟을 나타내십시오. 예:
# pragma target 3.5
# pragma require integers 2darray instancing
Unity는 기본적으로 지원하는 타겟 중 DirectX 셰이더 모델 2.0과 3.0 사이의 가장 낮은 타겟(“2.5”)으로 셰이더를 컴파일합니다. 일부 다른 컴파일 지시자는 셰이더가 자동으로 더 높은 타겟에서 컴파일되도록 만들수 있습니다.
#pragma geometry
) 컴파일 타겟을 4.0
으로 설정합니다.#pragma hull
또는 #pragma domain
) 컴파일 타겟을 4.6
으로 설정합니다.지오메트리, 헐 또는 도메인 셰이더에 대해 #pragma
를 통해 함수 엔트리 포인트를 명시적으로 설정하지 않는 셰이더는 내부 셰이더 성능 요구 사항을 다운그레이드합니다. 이렇게 하면 런타임과 기능에서 큰 차이가 있는 비DX11 타겟이 기존 셰이더 콘텐츠와 호환될 수 있습니다.
예를 들어 Unity는 Metal 그래픽스에 대해 테셀레이션 셰이더를 지원하지만, Metal은 지오메트리 셰이더를 지원하지 않습니다. 지오메트리 셰이더를 사용하지 않는 한 #pragma target 5.0
은 계속 사용할 수 있습니다.
아래 리스트는 지원되는 셰이더 모델을 성능의 오름차순으로 나열합니다(일부 경우 더 높은 플랫폼/GPU 요구 사항 순서).
es3.0
타겟의 모든 것이 포함됩니다.모든 OpenGL 유사 플랫폼(모바일 포함)은 “셰이더 모델 3.0 지원 가능”으로 간주됩니다. WP8/WinRT 플랫폼(DX11 기능 레벨 9.x)은 셰이더 모델 2.5만 가능한 것으로 간주됩니다.
#pragma require
지시문에 지원되는 기능 이름의 목록입니다.
interpolators10
: 버텍스에서 프래그먼트로 넘기는 인터폴레이터(“varyings”)가 10가지 이상 지원됩니다.interpolators15
: 버텍스에서 프래그먼트로 넘기는 인터폴레이터(“varyings”)가 15가지 이상 지원됩니다.interpolators32
: 버텍스에서 프래그먼트로 넘기는 인터폴레이터(“varyings”)가 32가지 이상 지원됩니다.mrt4
: 렌더 타겟이 여러 개(4개 이상)입니다.mrt8
: 렌더 타겟이 여러 개(8개 이상)입니다.derivatives
: 픽셀 셰이더 도함수 명령어(ddx/ddy)입니다.samplelod
: 명시적 텍스처 LOD 샘플링(tex2Dlod/SampleLevel)입니다.fragcoord
: 픽셀 셰이더의 픽셀 위치(화면: XY, 클립 공간: ZW 뎁스) 입력입니다.integers
: 정수는 실제 데이터 타입입니다(bit/shift 연산 포함).2darray
: 2D 텍스처 배열(Texture2DArray)입니다.cubearray
: 큐브맵 배열(CubemapArray)입니다.instancing
: SV_InstanceID 입력 시스템 값입니다.geometry
: DX10 지오메트리 셰이더입니다.compute
: 컴퓨트 셰이더, 구조화된 버퍼, 원자 연산입니다.randomwrite
: “random write”(UAV) 텍스처입니다.tesshw
: 하드웨어 테셀레이션을 위한 GPU 지원입니다. 단, 테셀레이션 셰이더 단계는 지원되지 않을 수 있습니다(예: Metal은 테셀레이션을 지원하나, 셰이더 단계를 통해 지원하지는 않음).tessellation
: 테셀레이션 헐/도메인 셰이더 단계입니다.msaatex
: 멀티 샘플 텍스처에 액세스할 수 있습니다(HLSL의 Texture2DMS).sparsetex
: 상주성 정보가 있는 스파스 텍스처(D3D에서 “Tier2” 지원, CheckAccessFullyMapped HLSL 함수)입니다. 현재 DX11/12에서만 구현됩니다.framebufferfetch
: Framebuffer 페치. 픽셀 셰이더에서 입력 픽셀 컬러를 읽을 수 있습니다.광범위한 #pragma target
지시문은 상기 요구 사항의 약어로, 다음에 상응합니다.
2.5
: derivatives3.0
: 2.5 + interpolators10 + samplelod + fragcoord3.5
: 3.0 + interpolators15 + mrt4 + integers + 2darray + instancing4.0
: 3.5 + geometry5.0
: 4.0 + compute + randomwrite + tesshw + tessellation4.5
: 3.5 + compute + randomwrite4.6
: 4.0 + cubearray + tesshw + tessellationDirect3D에서는 셰이더 모델 4.0이 “mrt8”도 의미하며, 셰이더 모델 5.0은 “interpolators32”와 “cubearray”를 의미합니다. 단, 이는 다수의 모바일 플랫폼에서 제공되지 않을 수도 있습니다. 따라서 기존 셰이더와의 이전 버전과의 호환성 측면에서는 #pragma target 4.0을 작성하더라도 자동으로 8 MRT 지원이 요구되지는 않으며, #pragma target 5.0을 작성하더라도 인터폴레이터 32개나 큐브맵 배열이 요구되지 않습니다.
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.