ãUE4ãGPUã³ã¹ãã®é«ãHZBã¨ã¯ã©ããªæ©è½ï¼
â»æ¬è¨äºã¸ã®ãã©ã¼ã©ã ãç«ã¡ä¸ãã¾ãããè²ããªãæè¦ãããã¾ããããæ¯éãã¡ãã®ãã©ã¼ã©ã ã§ãææãè°è«ããã¦ãããã°ã¨æãã¾ãã
HZBの仕組みと負荷の高さについてまとめました(2014 advent calender )
çºç«¯: HZBã¯Offã«ããã»ããè¯ãï¼
Oculuséçºãªã©ã®ããã«ãæè¿ã§ã¯UE4ã§ããã©ã¼ãã³ã¹ãåºãæ¹æ³ãããè°é¡ã«ãããã¾ãã
ãããªæã«ãã
"HZBããªãã«ãã¦ã¿ã¦ã¯ï¼"
ã¨ããæè¦ãèãã¾ãã
ä¾ãã°ãEpicGamesä¸ç°ããã®ãã®è¨äºã§ã¯ããã
Oculus Connectã§ã®Nickã®ãã¬ã¼ã³ãã¼ã·ã§ã³ã§Showdownãã¢ã®æé©åã§HZBã¯OFFã«ããã¨èª¬æãã¦ãã¾ããããr.HZBOcclusion 0ãã¨ã³ã³ã½ã¼ã«ã³ãã³ããæã¤äºã§OFFã«ã§ãã¾ãã
http://qiita.com/junyash/items/3ba225d8a2f86046cd23
ã¾ãUE4ã®å
¬å¼ã§ããæé©åã®ã¢ããã¤ã¹ã®é¨åã§ããã
Unreal Engine | GPU プロファイリング
ãªã¯ã«ã¼ã¸ã§ã³ ã«ãªã³ã°ï¼HZB ãªã¯ã«ã¼ã¸ã§ã³ã®è² è·ã¯å¸¸ã«é«ãã§ããããªãã¸ã§ã¯ãå½ããã®è² è·ã¯å°ããã§ããr.HZBOcclusion ãåãæ¿ãã¦ããªã³ã«ããªãã¦ã大ä¸å¤«ã確èªãã¾ãã
https://docs.unrealengine.com/latest/JPN/Engine/Performance/GPU/index.html
ãã®ããã«ãæé©åã®ç¬¬ä¸æã¨ãã¦ã
"HZBãOn/Offã«ãã¦è² è·ãè¨æ¸¬ããé«éãªæ¹ãé¸ã¶ã"
ã¨ããã®ãéä¾ã«ãªã£ã¦ãã¾ãã
ãã"HZBã¨ããæ©è½ã¯ä½ããã¦ãã®ï¼"ã¨ããæ¥æ¬èªè³æã¯ãç¾æç¹ã§ã¯ãã¾ããªãããã§ãã
ä»åã¯ãã®HZBã«ã¤ãã¦ç°¡åã«ã¾ã¨ãã¦ã¿ããã¨æãã¾ãã
ä½æ¥å¹çãåã«ãªã£ãããæ°ãã表ç¾ãã§ããããã«ãªããããã§ã¯ãªãã§ããã¹ãããªãããã人åãã§ãã
æ¤è¨¼ä¸ååã®ãã誤ããããããããã¾ãããããããããé¡ããã¾ãã
ã¢ã¸ã§ã³ã: UE4ã®HZB(Hierarchical Z-Buffer)ã«ã¤ãã¦
- HZBã¨ã¯ã©ããªãã¼ã¿ãï¼
- HZBãªã¯ã«ã¼ã¸ã§ã³ã«ãªã³ã°ã®ä»çµã¿
- HZBã¯ã©ããã¦è² è·ãé«ãï¼
- HZBãæå¹ãªã·ã¼ã³ã¯ï¼
- çµãã
- åè. ScreenSpaceReflectionã®BuildHZBã¯ï¼
æ¤è¨¼ãã¼ã¸ã§ã³ã¯UE4.6ãã¾ãDX11ã®ç¯å²ã®ã¿çµã£ã¦ããã¾ãã
(åºæ¬çãªã¢ã«ã´ãªãºã ã¯åããªã®ã§åé¡ç¡ãããã§ããï¼
ï¼HZBã¨ã¯æ¬æ¥ã¯ãã¼ã¿å½¢å¼ã§ãããUE4ã§ã¯HZBãç¨ãããªã¯ã«ã¼ã¸ã§ã³ã«ãªã³ã°ã"HZB"ã¨è¨ã£ã¦ããã®ã§ãä»åã¯HZB=HZBãªã¯ã«ã¼ã¸ã§ã³ã«ãªã³ã°ã¨ãã¦èª¬æããã¦ããã ãã¾ããï¼
1. HZBã¨ã¯ã©ããªãã¼ã¿ãï¼
ã¾ããHZBã¨ã¯Hierarchical Z-Bufferã®ç¥ã§ããååã®éããé層åãããZ-Bufferã§ããããããã¨ç¹æ®ãªãã®ã«èããã¾ãããã¤ã¾ããã ã®ãã¯ã¹ãã£ã®MipMapã§ãã
UE4ã§ã¯ã1ãã¬ã¼ã åã®Zãããã¡ãããã®HZBã¨ãããã¯ã¹ãã£ãä½æãã¾ãã
(ããã©ã«ãã¯ãä¸çªä¸ã512*256ãã¯ã»ã«ã§ã8段ã§ãã)
1ãã¬ã¼ã åã使ã£ã¦å¹³æ°ãªã®ãã¨è¨ãã¨ã30fps/60fpsã§ã¯1ãã¬ã¼ã åã®ããã¹ãç¾å¨ã®ãã¬ã¼ã ã®ããã¹ãã ãããåãã ããã¨ããåæã®ãã¨ã§è¡ã£ã¦ãããåé¡ã«ãªããããªã·ãã¢ãªã·ã¼ã³ã¯æ®ã©ãªãã¨èãããã¦ãã¾ãã
ãã ããã®Mipmapã®ä½æã¯ä¸å·¥å¤«ããã¦ãã¾ããUE4ã®HZBã¯ãè¿é£ã®ããã¹å¤ã®ä¸ããã"ä¸çªé ãããã¹å¤"ãé¸ãã§MipMapãä½æãã¦ããã¾ããï¼ä¸å³ï¼
ãã®HZBã使ã£ã¦ãå¾ã«ãªã¯ã«ã¼ã¸ã§ã³ã«ãªã³ã°ãè¡ãã¾ãã
2. HZBãªã¯ã«ã¼ã¸ã§ã³ã«ãªã³ã°ã®ä»çµã¿
åã®ç¯ã§ä½æããHZBã使ã£ã¦ããªã¯ã«ã¼ã¸ã§ã³ã«ãªã³ã°ãè¡ãã¾ãã
ãªã¯ã«ã¼ã¸ã§ã³ã«ãªã³ã°ã¨ã¯ãåæ¯ã®ãªãã¸ã§ã¯ãã«ãã£ã¦å®å
¨ã«è¦ããªããªãã¸ã§ã¯ããåãã£ã¦æ¢ãã¦ãããããããã¬ã³ããªã³ã°è¨ç®ããé¤å¤ãã¦è¨ç®ã³ã¹ããä¸ããææ³ã§ãã
ä¸éæãªå£ã®è£ã«500ä¸ããªã´ã³ã®ãã£ã©ã¯ã¿ããã¦ããæ ããªãäºãå¤å®ãã¦åãã£ã¦çãã¦ããã®ã§ã(GPUã®)ã¬ã³ããªã³ã°ã³ã¹ããæ¸ããã¦ããã¾ãã
ã§ã¯ã©ããã£ã¦ããããªãã¸ã§ã¯ããè¦ãããè¦ããªãããå¤å®ãããï¼é常ã«åç´ãª3å·¥ç¨ãªã®ã§ä»¥ä¸ã§ç°¡åã«èª¬æãã¾ãã
2-1. ãªãã¸ã§ã¯ãã®ãã¦ã³ãã£ã³ã°ããã¯ã¹ãã¹ã¯ãªã¼ã³ã®ã©ããããã®ç¯å²ã«æç»ããããã調ã¹ã¾ãã
2-2. 1ã§èª¿ã¹ãç¯å²ã®Zå¤ããåãã£ã¦ä½ã£ã¦ç½®ããHZBããèªã¿è¾¼ã¿ã¾ããããã¯ãâãã¦ã³ãã£ã³ã°ããã¯ã¹ã®æç»ç¯å²ã§æé ã®ããã¹å¤âã¨ãªãã¾ãã
ãã®ã¨ãããã¦ã³ãã£ã³ã°ããã¯ã¹ãå
å
ã§ããMipã®ã¬ãã«ã調ã¹ã¦ãããããããèªã¿è¾¼ã¿ã¾ãã
(åè)ãããå端ãªã¨ããã«ããã¯ã¹ãããå ´åã4è¿åã®å¨ãã®ããã¹ãåã£ã¦æ¥ã¦ããããã®æé ã®ããã¹å¤ã使ã£ããããã¦ã¾ãã
2-3. "(HZBããèªã¿è¾¼ãã )ãã®ç¯å²ã®ä¸çªé ãããã¹"ããããã"ãã¦ã³ãã£ã³ã°ããã¯ã¹ãå®å ¨ã«å¾ãã«ããå ´å"ããªãã¸ã§ã¯ãã¯çµ¶å¯¾ã«æ ããªãã®ã§ãæç»ãããªãç¨ãã©ã°ãã¤ããã
ã¾ã¨ããã¨ä»¥ä¸ã®æµãã§ãã
HZBãªã¯ã«ã¼ã¸ã§ã³å¤å®ã®æµã(SubmitHZB(ã®TestHZB))
- ãªãã¸ã§ã¯ãã®ãã¦ã³ãã£ã³ã°ããã¯ã¹ãã¹ã¯ãªã¼ã³ã®ã©ããããã®ç¯å²ã«æç»ããããã調ã¹ã¾ãã
- ãã®ç¯å²ã®æé ã®Zå¤ããåãã£ã¦ä½ã£ã¦ç½®ããHZBããèªã¿è¾¼ã¿ã¾ãã
- "(HZBããèªã¿è¾¼ãã )ãã®ç¯å²ã®ä¸çªé ãããã¹"ããããã"ãã¦ã³ãã£ã³ã°ããã¯ã¹ãå®å ¨ã«å¾ãã«ããå ´å"ããªãã¸ã§ã¯ãã¯çµ¶å¯¾ã«æ ããªãã®ã§ãæç»ãããªãç¨ãã©ã°ãã¤ããã
ãã®ããã«ãã¦ãã©ããªé«ããªã´ã³ã®ãªãã¸ã§ã¯ãã ããã¨ããã¦ã³ãã£ã³ã°ããã¯ã¹ã¨HZBãã¯ã¹ãã£ã®æ¯è¼ã®ã¿ã§æ¸ãã®ã§ãé常ã«ä½è² è·ã«ãªã¯ã«ã¼ã¸ã§ã³å¤å®ãã§ãã¾ãã*1
ã
ã
ã
ãããããªãã§éãããã ãï¼
3. HZBã¯ã©ããã¦è² è·ãé«ãï¼ï½GPUâCPUã¸ã®ãã¼ã¿è»¢éã®éãããï½
ä¸ã§èª¬æããã¨ãããHZBã§ãããã¨ã¯ï¼ã¤ã
- HZBãä½ãã(BuildHZB)
- HZBã使ã£ã¦ãè¦ããªããªãã¸ã§ã¯ããç®åºããã(SubmitHZB)
UE4å ã§ãã®ï¼ã¤ã®ä½æ¥ã¯BuildHZB, SubmitHZBã¨å¼ã°ãã¾ãã
å®éã«ProfileGPUã®ä¸èº«ãè¦ã¦ã¿ã¾ãã
ãã®ä¸ã®HZBã®ä¸ãè¦ã¦ã¿ãã¨ã確ãã«BuildHZBãSubmitHZBãããã¾ãã
ããè¦ãã¨ãHZBãä½æãã¦ããBuildHZBã¯å¦çè² è·ãå
¨ãããã£ã¦ãã¾ãããã¨ãããä»åã®å ´åãHZBã®è² è·ã®1%ã«ããªã£ã¦ãã¾ããï¼
ãããããããä½ã£ã¦ããã ããªã®ã§ãããã¾ã§éãããªããã¨ã¯ç¢ºãã«ãªãããã§ãã
å¦çè² è·ã®99%ã¯ãSubmitHZBã§ããããã§SubmitHZBã®ä¸ãè¦ã¦ã¿ãã¨ãã
TestHZBã¨ããã®ã0.02åºã¦ãã¾ãããããã¯å®ã¯SubmitHZBã®âè¦ããªããªãã¸ã§ã¯ããç®åºããâã¨ããã¡ã¤ã³ã®é¨åã§ãããã¯ããã¡ãã軽ãã®ã§ãããã¦ã³ãã£ã³ã°ããã¯ã¹ã¨ãã¯ã¹ãã£(HZB)ã®å¤ãæ¯è¼ãã¦ããã ãã§ãããã(ã§ãã®ã§ã大éã«ãªãã¸ã§ã¯ãããã£ãã¨ãã¦ãããã®é¨åã®è² è·ãè·³ãä¸ããã¯ããªãã¨èãããã¾ãã)
ã¨ãããã¨ã§HZBã®ã¢ã«ã´ãªãºã ã®å¤ã§ã98%以ä¸ã®è² è·ãããã£ã¦ãã¾ãã
ã§ã¯ä½ããã£ã¦ãããã¨ããã¨ãã
HZBã®ã¡ã¤ã³ã®ããã«ããã¯ã¯ããªã¯ã«ã¼ã¸ã§ã³ã®å¤å®çµæãGPUããCPU(ã®ã¡ã¢ãª)ã«è»¢éãã¦ããããã§ãã
ã¨ããã®ãçãã«ãªãã¾ãã
HZBã®ä½æãããªã¯ã«ã¼ã¸ã§ã³ã®ãã¹ãããã©ã¡ããGPUã§è¡ããã¦ãã¾ããã¨ãããã¨ã¯ãCPUå´ã«âã©ã®ãªãã¸ã§ã¯ããè¦ãã¦ãã©ã®ãªãã¸ã§ã¯ãã¯è¦ããªãï¼âã¨ããçµæãè¿ãã¦ãããªããã°ããã¾ããã
å³ã®ããã«ããªã¯ã«ã¼ã¸ã§ã³ã®å¤å®(TestHZB)ãGPUã§è¡ããããããGPUå´ã¯ãªã¯ã«ã¼ã¸ã§ã³ã®å¤å®çµæãCPUã«æ»ãã¦ãããªãã¨ããã¾ããããããé常ã«éããåå ã§ãããããã転éã³ã¹ãã¯ä¸å®ãªã®ã§ãã¦ã¼ã¶ãã¢ã»ããã®ä½ãæ¹ãã¬ãã«ã®ä½ææ¹æ³ãªã©ã§åæ¸ã§ããªãé¨åã§ãã
4. HZBãæå¹ãªã·ã¼ã³ã¯ï¼ï½Oculusã«ã¯ç¡çãããï¼ï½
ãã¼ãããããè²ã
ã¨èª¿æ»ãã¦ããã®ã§ãããå
·ä½çã«å¤æãã¦ããã¾ããã
å®éãHZBã«ãã£ã¦æ²¢å±±ã®ãªãã¸ã§ã¯ããã«ãªã³ã°ããããããªã·ã¼ã³ããããããã®ãå¾®å¦ãªæ°ããã¾ããï¼èª¿æ»ä¸è¶³ãªã®ã¯å¦ãã¾ããããï¼
ã¨ããã®ãããã®"ã«ãªã³ã°"ã¨ããå·¥ç¨ã¯HZBãªã¯ã«ã¼ã¸ã§ã³ã ããããªããè¦éã®å¤ã®ãªãã¸ã§ã¯ããé¤å¤ãããã©ã¹ã¿ã ã«ãªã³ã°ãã¹ã¿ãã£ãã¯ãªãªãã¸ã§ã¯ãã®è¦ããé åãåãã£ã¦è¨ç®ããPrecomputed Visibilityãªã©è²ã ããã¾ããæ·±ãæ¤è¨¼ã¯ãã¦ãã¾ããããHZBãããåã«èµ°ãä¸è¨ï¼ã¤ã®ã«ãªã³ã°ãé常ã«ããå¹ããHZBã¾ã§è³ããªãã¸ã§ã¯ãã¯ãããªã«ãªãã®ã§ã¯ï¼ï¼ã¨èãã¦ãã¾ãã
åçã«åãå£ã«ãã£ã¦é ãã大éã®ãã£ã©ã¯ã¿ããããªã®ãã¨ãèãã¾ããããã¡ãã£ã¨èª¿ã¹ããã¦ããã¾ãããæµ·å¤Forumã§ãæå¹ãªæè¦ã¯çºè¦ã§ããªãã£ãã®ã§ãã¿ãªå¹ãç®ã模索ãã¦ããã¨ããã§ãããããä½ãã«ãããåçãªãªãã¸ã§ã¯ãã大éã«åºã¦ããç©éã®å¤ãã·ã¼ã³ã§ããHZBã¯å¹ãã¦ããã¨æããã¾ãã
ããããæè¨ã§ããããªäºãããã¾ããOculusã§75FPS(ã¯ãã¾ãä»å¾ã¯90FPS)ãåºããã¨ããã¨ãCPU/GPUå
±ã«ããªãã·ãã¢ã«è² è·ãå¶å¾¡ããªããã°ããã¾ããã
90FPSåºããã¨ãããªãã°ãCPUã®å¶éãããããããªã«å¤§éã®ãªãã¸ã§ã¯ããæå
¥ã§ããããããã¾ãããçµæãHZBãå¹æçã«å¹ãã·ã¼ã³ããããããä½ããªãå¯è½æ§ãé«ãã§ãã
ã¨ãããã¨ã§ããã¯ãæåã®ææ¡ã«è³ãã¾ãã
"HZBããªãã«ãã¦ã¿ã¦ã¯ï¼(ç¹ã«Oculusãããªã)"
5. ããã
èªãã§é ããããã¨ããããã¾ãã
HZBã«ã¤ãã¦ç°¡åã«ã¾ã¨ãã¦ã¿ã¾ããã
âååã¯èããã©ãä½ãã¦ãã®ï¼âã¨æã£ã¦ããæ¹ã
ãå°ãã§ããã£ããã§ããã幸ãã§ãã
ã½ã¼ã¹ãèªãã§ãé¢ç½ããã¨ãªã©ãè²ã
çºè¦ã§ããã®ã§ãããã¯ã¾ãå¾æ¥æ¹ãã¦ã¾ã¨ãããã¨æãã¾ãï¼
次åã¯とげとげさん@火曜西く25a (@checkela) | Twitterããã®"UE4ã§ãã¯ããã«å¯æãè¸ã£ã¦ãããæ¹æ³ï¼äºå®ï¼"ã§ãï¼è¯ã®ããæ稿ã«ãªããããªã®ã§ããã¾ãã楽ãã¿ã§ãï¼
Unreal Engine 4 (UE4) Advent Calendar 2014 - Qiita
åè: SSR(ScreenSpaceReflection)ã®BuildHZBã¨ã¯ï¼
r.HZBOcclusionã®On/Offã«é¢ä¿ãªããSSR(ScreenSpaceReflection)ãOnã«ããã¨ãBuildHZBãããã¾ãã
å®ã¯SSRãHZBã使ãã¾ãããããHZBãªã¯ã«ã¼ã¸ã§ã³ã§å
ã«HZBãä½æãã¦ããå ´åãSSRã§å¼ã°ããBuildHZBã¯ä½ããã¾ããããããHZBãªã¯ã«ã¼ã¸ã§ã³ããªãã«ãã¦ãå ´åãSSRãè¨ç®ããã¿ã¤ãã³ã°ã§BuildHZBã«ããHZBãä½æããã¾ãããããã«ãããBuildHZBã¯HZBãä½æããä½æ¥ãªã®ã§ãè² è·ã¯ã»ã¨ãã©ããã¾ããã
âããï¼HZBOcclusionãOffã«ããã¯ããªã®ã«BuildHZBã¨ãããã®ããããã¡ã¤ã«ã«åºã¦ããããâã¨èãã¦ãæ¹ã¯æ°ã«ããªãã§å¤§ä¸å¤«ã¨æãã¾ãã
SSRã®å
é¨ã§ãé«éãã¤ç²ãRaycastãè¡ãããã«HZBå¿
è¦ã¨ãã¦ãã¾ãã
ã§ãããHZBãªã¯ã«ã¼ã¸ã§ã³ã®ããã«CPUã«çµæãæ»ãããããªãã¨ããããããããSubmitHZBã®ä½æ¥ã¯SSRã§ã¯å
¨ãèµ°ããªãã®ã§åé¡ãªãã¨ãããã¨ã§ãã
ããã¨ã¯é¢ä¿ãªããSSRãéãã§ããã©ããã
*1:æ£è¦åããã¤ã¹åº§æ¨ç³»ã¸ã®å¤æãã©ã®Mipã¬ãã«ãé¸ã¶ããªã©ã¯å¿è«ããã¾ãããé«è² è·ã¨ã¯ããã¾ããã