Unity에서 HLSL 프로그래밍 언어를 사용하여 셰이더 프로그램을 작성할 수 있습니다.
이 매뉴얼 섹션은 Unity 고유의 방식으로 HLSL을 사용하는 방법에 대한 정보를 포함합니다. HLSL 작성에 대한 일반 정보는 Microsoft의 HLSL 문서를 참조하십시오.
참고: 원래 Unity는 Cg 언어를 사용했으므로, Unity의 일부 키워드 이름(CGPROGRAM
)과 파일 확장자(.cginc
)에 “cg”가 포함되어 있습니다. Unity는 더 이상 Cg를 사용하지 않으나, 이러한 이름은 아직 사용됩니다.
ShaderLab 코드의 코드 블록 안에 HLSL 코드를 넣습니다. 그러면 보통 다음과 같이 표시됩니다.
Pass {
// ... the usual pass state setup ...
HLSLPROGRAM
// compilation directives for this snippet, e.g.:
#pragma vertex vert
#pragma fragment frag
// the shader program itself
ENDHLSL
// ... the rest of pass ...
}
셰이더 코드 블록에 대한 자세한 내용은 ShaderLab: 셰이더 프로그램 추가를 참조하십시오.
HLSL에는 두 개의 구문이 있습니다. 하나는 레거시 DirectX 9 스타일 구문이며, 다른 하나는 보다 최첨단의 DirectX 10+ 스타일 구문입니다. 두 구문의 주된 차이점은 텍스처 샘플링 함수의 작동 방식입니다.
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.