HLSL의 #include
지시문은 프리 프로세서 지시문의 일종입니다. 이 지시문은 컴파일러가 한 HLSL 파일의 콘텐츠를 다른 HLSL 파일 내에 포함하도록 지시합니다. 이렇게 포함하는 파일은 include 파일이라고 합니다.
Unity에서 일반 #include
지시문은 표준 HLSL과 동일하게 작동합니다. 일반 #include
지시문에 대해 자세히 알아보려면 HLSL 문서인 include 지시문을 참조하십시오.
Unity는 추가적으로 Unity 전용 #include_with_pragmas
지시문도 제공합니다. #include_with_pragmas
지시문은 일반 #include
지시문과 동일하게 작동하지만, include 파일에서 #pragma
지시문을 사용할 수 있게 하기도 합니다. 즉, #include_with_pragmas
지시문을 사용하면 여러 파일에서 #pragma
지시문을 공유할 수 있습니다.
참고: #include_with_pragmas
지시문을 사용하려면 캐시 셰이더 프리 프로세서를 활성화해야 합니다.
이 예시는 Unity 전용 #include_with_pragmas
지시문을 사용하여 일반적인 워크플로 개선, 즉 매번 모든 셰이더 소스 파일을 수정하지 않고도 여러 개의 셰이더에 대해 셰이더 디버깅을 토글하여 켜고 끌 수 있는 기능을 활성화하는 방법을 보여줍니다.
다음 줄은 include 파일의 콘텐츠를 나타냅니다. 이 콘텐츠는 셰이더 디버깅을 활성화하는 하나의 pragma 지시문을 포함합니다.
// Comment out the following line to disable shader debugging
# pragma enable_d3d11_debug_symbols
디버그할 각 셰이더에 include 파일을 가리키는 #include_with_pragmas
지시문을 추가합니다. 다음과 같이 이 지시문을 다른 #pragma
지시문 근처에 배치하십시오.
// Example pragma directives
# pragma target 4.0
# pragma vertex vert
# pragma fragment frag
// Replace path-to-include-file with the path to the include file
# include_with_pragmas "path-to-include-file"
// The rest of the HLSL code goes here
이제 include 파일을 사용하는 모든 셰이더에 대해 셰이더 디버깅을 토글하여 켜거나 끄려면 include 파일에서 한 줄만 변경하면 됩니다. Unity는 셰이더를 다시 컴파일할 때 수정된 줄을 포함합니다.
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.