로깅 및 프로파일링 툴을 사용하여 Unity가 컴파일하는 셰이더 배리언트 수를 확인하고, 배리언트를 제거(스트리핑)하여 빌드 시간을 개선하고 메모리 사용량을 줄일 수 있는 방법을 확인할 수 있습니다.다음을 수행할 수 있습니다.
씬 뷰와 게임 뷰에서 에디터가 사용하는 셰이더 배리언트 리스트를 생성할 수 있습니다.이 작업을 수행하는 방법은 다음과 같습니다.
프로젝트를 빌드한 후 Editor.log
로그 파일을 열고 Compiling shader
를 검색하여 Unity가 어떤 배리언트를 컴파일하고 스트리핑하는지 확인합니다.예시:
Compiling shader "Universal Render Pipeline/Lit" pass "ForwardLit" (fp)
320 / 786432 variants left after stripping, processed in 6.77 seconds
starting compilation...
finished in 29.72 seconds.Local cache hits 202 (0.24s CPU time), remote cache hits 0 (0.00s CPU time), compiled 118 variants (582.41s CPU time), skipped 0 variants
URP(유니버설 렌더 파이프라인) 또는 HDRP(고해상도 렌더 파이프라인)를 사용하는 경우 Unity가 컴파일하고 스트리핑한 총 배리언트 개수를 기록할 수도 있습니다.다음에서 Shader Stripping > Shader Variant Log Level에서 Disabled가 아닌 로깅 레벨을 선택하십시오.
그러면 Editor.log
에 Total
로깅이 추가됩니다.예시:
STRIPPING:Universal Render Pipeline/Lit (ForwardLit pass) (Fragment) - Remaining shader variants = 640/5760 = 11.11111% - Total = 2657/10169 = 26.12843%
Editor.log
의 위치는 로그 파일을 참조하십시오.
Unity에서 GPU용 셰이더를 컴파일할 때 콘솔 창에 ‘Compiled shader’ 메시지를 출력합니다.
메모리 프로파일러 모듈 또는 Memory Profiler 패키지를 사용하여 런타임에 셰이더가 얼마나 많은 메모리를 사용하는지 확인하십시오.셰이더가 많은 메모리를 사용하는 경우 해당 배리언트를 스트리핑하는 실험을 해볼 수 있습니다.
Unity 2022.2 이상에서는 머티리얼에서 누락된 셰이더 배리언트를 사용하려고 할 때 런타임 중에 분홍색 오류 셰이더를 강제로 표시하게 만들 수 있습니다.
이것은 strictShaderVariantMatching
을 사용하여 C# 스크립트에서도 활성화할 수 있습니다.
이렇게 하면 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.