Stationary Light ã®å½±ã«ã¤ãã¦
ãã®è¨äºã¯Unreal Engine 4 (UE4) 其の弐 Advent Calendar 2015ã®16æ¥ã®è¨äºã§ããæ¨æ¥ã¯じゅる (@xxJulexx) | Twitterããã®映像クリエータ視点な使い方とか。ã§ãããããããã³ã³ãã¸ããããªãã©ã¤ã³ã§ãããã¨ãåæã«ãBasePassã¨ä¸é¨ã®ãã¹ãã¨ãã§ã¯ãããã®ã¾ã¾åºåã§ããæ©è½ãããã°ãUE4ã®æ åå¶ä½ããã£ã¨æãããã§ããã
ä»åã¯ã©ã¤ãã£ã³ã°ã®ç´°ãã話ããããã¨æãã¾ãããªãã¨ãªãè¨å®ãã¦ãã人ãå¤ããã¹ãã¼ã·ã§ããªã¼ã©ã¤ãã®ä»çµã¿ã§ããã«ã¿ã«ãã¨è±èªãä¹±ç«ãã¾ãããæ°ãåãããç´ããã¦ãã ããã
UE4ã®ã©ã¤ãã£ã³ã°ã¯æ§ã ãªçµã¿åããã«å¿ãã¦å é¨å®è£ ãå¤ããã¾ã
é«ã¯ãªãªãã£ãªã©ã¤ãã£ã³ã°ãåºãã¤ã¤ãä¸å®ã®ããã©ã¼ãã³ã¹ãåºãããå ´åãªã©ã§ã¯ãä½æããã©ã¤ãã£ã³ã°ç°å¢ãå
é¨ã§ã©ããªè¨ç®ããã¦ããããææ¡ããå¿
è¦ãããã¾ãã
ä»åã¯ãä¸éæ(Maskedãå«ã)ãªãã¸ã§ã¯ãã«å¯¾ãã¦ãStationary Lightã®å½±ãã©ããªåä½ãããããç°¡åã«èª¬æãã¦ããããã¨æãã¾ãã
話ã¯StaticãªMeshãMovableãªMeshãã§äºåããã¾ãã
Static Meshã®å½±ã«ã¤ãã¦
Stationary Lightã¯ãªãã§5å以ä¸éãã¡ããããªãï¼
ã¹ãã¼ã·ã§ããªã¼ã©ã¤ãã®é°ã§ãããå ¬å¼ãµã¤ãã§ã¯ãã®ããã«è¿°ã¹ããã¦ãã¾ãã
ã©ã¤ãã㹠㯠Stationary light (åºå®ã©ã¤ã) ã«å¯¾ã ãã£ã¹ã¿ã³ã¹ ãã£ã¼ã«ã ã·ã£ãã¦ããã ãçæãã¾ãã
...
ã©ã¤ãã¯ãã·ã£ãã¦ããã ãã¯ã¹ãã£ã®ç°ãªããã£ã³ãã«ã¸ã®å²ãå½ã¦ãå¿ è¦ãªããã 4 ã¤ã¾ãã¯ãã以ä¸ã®ãªã¼ãã¼ã©ãããã Stationary light (åºå®ã©ã¤ã) ã®ã¿ãéçã·ã£ãã¦ã表ç¾ãããã¨ãã§ãã¾ãã
Unreal Engine | Stationary lights (固定ライト)
ã©ããä¸åã®ãªãã¸ã§ã¯ãã«5å以ä¸ã®ã¹ãã¼ã·ã§ããªã¼ã©ã¤ããéãªãã¨ããã®ã©ã¤ãã®ä¸ã®ï¼åã¯ã¹ãã¼ã·ã§ããªã¼ã©ã¤ãç¨ã®ã·ã£ãã¦ãããã§ã¬ã³ããªã³ã°ã§ãã¾ãããæ®ãã®ã©ã¤ãã¯ã·ã¼ã³å
¨ä½ãåçã«ã·ã£ãã¦è¨ç®ãããã¨ã«ãªãã¾ãã5å以ä¸ã¹ãã¼ã·ã§ããªã¼ã©ã¤ããéãªãã¨ãUE4ã¯èªåçã«ãã©ã®ã©ã¤ããåçã·ã£ãã¦è¨ç®ã«ããã決ãã¾ããä¸ã®å³ã§Ãå°ãã¤ãã¦ããã®ãåçè¨ç®ã¨ã¿ãªãããã©ã¤ãã§ããæ®å¿µãªããã©ã®ã©ã¤ãã仲éå¤ãã«ããããèªåã§æ示ã§ããªããã§ãã
ããã¾ã§ã¯ã¿ãªãããåç¥ãã¨ãæãã¾ããã§ããããããªãã§ãªãã§ãããï¼ï¼
ã¹ãã¼ã·ã§ããªã¼ã©ã¤ãã®ã·ã£ãã¦ããããæã¤ã®ã¯ã©ã¤ãã§ã¯ãªãã(ã¹ã¿ãã£ãã¯ãª)ã¡ãã·ã¥ã§ãã
ã¹ãã¼ã·ã§ããªã¼ã©ã¤ãã®ã·ã£ãã¦ãããã¯ãã·ã¼ã³ã«ç½®ãããåã¹ã¿ãã£ãã¯ã¡ãã·ã¥ãæã¡ã¾ããã¹ã¿ãã£ãã¯ã©ã¤ããã©ã¤ããããã«ãã¤ã¯ãããã®ã¨åæ§ã§ãããã®æ¶è²»ãã¼ã¿ã¯ãStatãè¦ã㨠NumSM / TextureSMã¨ãã£ãé
ç®ã§ç¢ºèªã§ãã¾ãã
NUM SMã5ã¨æ¸ãã¦ããã®ã¯ãéãªã£ã¦ããã©ã¤ããã«ã¦ã³ãããã¦ããããã§ãããTextureSMã®ãµã¤ãºãè¦ãã¨ã4åã®ããããæã£ã¦ãããã®ã¨ãã¼ã¿éãå¤ãããªãã®ãããããã¨æãã¾ããå®ã¯ãã¹ãã¼ã·ã§ããªã¼ã©ã¤ãã¯èªèº«ã«ã©ã¤ãã®ã¤ã³ããã¯ã¹çªå·ã1ã¤(0~3ã®å¤)æã¡ããã®ã¤ã³ããã¯ã¹ã«å¯¾å¿ããã·ã£ãã¦ãããã«èªèº«ã®å½±ãæ¸ãè¾¼ãã®ã§ãããã®ã¤ã³ããã¯ã¹ã¯UE4ãåæã«å é¨ã§æ±ºãã¾ãã
ã©ã®ã©ã¤ãã仲éå¤ãã«ãªãã®ãï¼ãæ°ã«ãªãæ¹ã¯ULightComponent::ReassignStationaryLightChannelsé¢æ°ã®ä¸èº«ãåèã«ããã¨è¯ãã¨æãã¾ãã
Stationary Lightã®Shadow Mapã¯ãG-Bufferãçµç±ãã¦ã©ã¤ãã£ã³ã°è¨ç®æã«åç §ããã¾ã
ä¸å³ã®ããã«ãã¹ã¿ãã£ãã¯ã¡ãã·ã¥ã«ç¼ãããã·ã£ãã¦ãããã¯G-Bufferã«åãè¾¼ã¾ãã¦ãã©ã¤ãã£ã³ã°è¨ç®ã«éããã¾ããã¹ãã¼ã·ã§ããªã¼ã©ã¤ãã®ããã®è¨ç®ãG-Bufferã®åå¾ã«ããã®ã¯éå¹çã«è¦ããããããã¾ãããã§ãããã©ã³ã¿ã¤ã ã§ã®ããã¹æ¯è¼ãç¨ããã·ã£ãã¦è¨ç®ããªããããé«éãã¤é«ç²¾ç´°ãªå½±ãã¹ãã¼ã·ã§ããªã¼ã©ã¤ãã§å®ç¾ã§ãã¦ããã®ã§ãã
ããããã¹ã¿ãã£ãã¯ãªã¡ãã·ã¥ãã¹ã¿ãã£ãã¯ãªã¡ãã·ã¥ã«ãã£ã¦åããã¹ãã¼ã·ã§ããªã¼ã©ã¤ãã®å½±ã®è¨ç®ã§ããã¤ã¾ããåçãªãã¸ã§ã¯ããé¢ä¿ããå ´åããã¡ããæåã¯å¤ããã¾ãã
Movable Meshã®å½±ã«ã¤ãã¦
Movable ObjectãStationary Lightã«åã¼ãå½±
次ã¯Movableãªã¡ãã·ã¥ãStationary Lightãåã¼ãå½±ã«ã¤ãã¦ã§ããä¸è¨ã§ã ãã ã話ãã¦ããã·ã£ãã¦ãããã®ãã¨ã¯ããå
¨ãé¢ä¿ããã¾ãããå¿ãã¦ãã ããã話ãå¤ãã¦ã以ä¸ã®ãããªãã¤ã³ãã©ã¤ãä¸åã®ã·ã¼ã³ãèãã¾ããå¨ãã«æµ®ãã¦ããã®ã¯ãã¹ã¦Movableã«è¨å®ããããªãã¸ã§ã¯ãã§ãã(注: Directional Lightã¯Cascade Shadowã使ããã®ã§ä»åã¯ãã¤ã³ãã©ã¤ããã¹ãããã©ã¤ãã«éå®ãã¾ããå¾ã§èª¬æãã¾ãã)
ãã®ã¨ããStationary Lightã¯ãMovableãªMeshæ¯ã«ã·ã£ãã¦ããããã¤ããã¾ããå®éã«ã·ã£ãã¦ãããããã£ããã£ããã¨ä»¥ä¸ã®ãããªãã¯ã¹ãã£ã§ãã
å·¦ä¸ã«å°ãããªãã¸ã§ã¯ããæç»ããã¦ããã®ããããã§ããããï¼å·¨å¤§ãªã·ã£ãã¦ãããä¸æãã°ãªããä¸ã«åå²ããåãªãã¸ã§ã¯ããåã¼ãã·ã£ãã¦ããããä½ã£ã¦ãã¾ãã
ãã®å¾ãå
¨ã¦ã®Meshæ¯ã«ãShadowã®å½±é¿ãã¬ã³ããªã³ã°ããã¾ããå®éã«ä¸ã¤ã®ãªãã¸ã§ã¯ãã«å¯¾ãã¦ã©ã¤ãã£ã³ã°ãããçµæãè¦ãã¨ã以ä¸ã®ãããªé»è²ãé¨åããï¼ã¤ã®ãããªãã¸ã§ã¯ããé¢ä¸ããå½±é¨åã®æç»ã§ãã(æç»ç¯å²ã¯Shadow Frustumã®ã¹ãã³ã·ã«ãã¹ãã§æå®ãã¦ãã¾ãã)
ã¤ã¾ããMovable Meshã«æ¼ããStationary Lightã®å½±ã®ã³ã¹ãã¯ä»¥ä¸ã«ãªãã¾ãã
Movable Meshã«ãããStationary Lightã®å½±ã®ã³ã¹ã =
ã©ã¤ãã®å½±é¿ä¸ã«ããMovable Meshã®æ°ã* ä¸ã¤ä¸ã¤ã®ã·ã£ãã¦çæåã³æç»ã³ã¹ã
Stationary Lightã®Shadowã¯ãMovable Meshæ¯ã«è¨ç®ããã
(Directional Lightã¯Cascade Shadow MapãDF Shadowã«ãããã®å¶éãåãã¾ããï¼Directional Lightã®æåã¯UE4 Docãåç §ãã¦ãã ããã)
ãã¦ãå
ã»ã©ã®ããã«ãStationary Lightã®Shadowã¯ãMovableãªMeshã«å¯¾ãã¦ä¸åãã¤Shadow Mapãä½æãããã¬ã³ããªã³ã°ãä¸åãã¤è¡ãããã¨è¨ãã¾ããããã®ç¶æ³ã§ä¾ãã°ãã©ã¤ãã®å½±é¿ç¯å²å
ã«æ²¢å±±Movable Meshãããã¦ã¿ã¾ãã
ããã ãç½®ããå¾ã®ShadowMapã¯ä»¥ä¸ã®ããã«ãShadowMapã§æç»ããããªãã¸ã§ã¯ããå¢ãã¦ããã®ããããã¾ãã
ããã¦ããã®ãã¨ãã®å¤§éã®ãªãã¸ã§ã¯ãï¼ã¤ï¼ã¤ã«å¯¾ãã¦å½±ã®å½±é¿ãè¨ç®ãã¾ãã
å®éã«ProfileGPUã§è¦ã¦ã¿ãã¨ãShadowMapä½æãã§ã¤ãºã®ShadowDepthsFromOpaqueProjectedã§å¤§éã®ã¡ãã·ã¥æ¯ã®ã·ã£ãã¦ããããä½æããã¦ããã®ããããã¾ããä¸å³ã®èµ¤ãã·ã£ãã¦ããããä½æãã¦ãããã§ã¤ãºã§ããã
ãã®ãã¨ãå®éã®å½±ã®å½±é¿ãè¨ç®ãããã§ã¤ãºã®ShadowProjectionOnOpaqueãè¦ã¦ã¿ãã¨ãåã¡ãã·ã¥ã«å¯¾ãã¦ãå®éã®ã·ã£ãã¦ãè¨ç®ãã¦ããã®ããããã¾ãã
ãããStationary Lightã®å½±é¿ç¯å²å ã«MovableãªMeshã大éã«ç½®ãã¨éããçç±ã§ãã
Stationary Lightã¯ãMovable Meshæ¯ã«å¥ã
ã«å½±ã®è¨ç®ããããå¥ã
ã«å½±ã®è¨ç®ããããããMovable Meshãå¢ããã°å¢ããã»ã©ã³ã¹ãã®å¢å¤§ãæ¿ããããã®ä¸æ¹ãLightãMovableã«ããã¨ãShadowã¯Meshåä½ã§ã¯ãªããã©ã¤ãä¸åã«å¯¾ãã¦ã¾ã¨ãã¦è¨ç®ããã¾ãã
ãªã®ã§ãStationary Lightã®å¦çè² è·ã¯MovableãªMeshã®æ°ã«ä¾åãã¦ãã¾ãã®ã§ããã®ããã«åçãªãªãã¸ã§ã¯ãã«å¯¾ããå½±é¿ãå¤ãã©ã¤ãã¯Movableã«ããã»ããå½±ã®ã³ã¹ããä¸ãããã¨ãããã®ã§ãã
確èªã®ããã試ãã«ãã©ã¤ããMovableã«ãã¦ã¿ã¾ãã
ãããã¦ãããã¡ã¤ãªã³ã°ããã¨ãå½±æç»ãWholeSceneã¨ããä¸ã¤ã«ã¾ã¨ãããã¦ãåè¨ã®æç»ã³ã¹ããä¸ãã£ã¦ããã®ããããã¾ããã·ã¼ã³å
¨ä½ã§ä¸ã¤ã®ã·ã£ãã¦ããããä½æãä¸åã§ã¬ã³ããªã³ã°ããMovableã®ã©ã¤ãã®æ¹ããMovableãªMeshæ¯ã«å½±ãæç»ããStationary Lightã®å½±ãããå¦çè² è·ã軽ããªãè¯ãä¾ãã¨æãã¾ãã
Directiona Lightã®å½±ã«ã¤ãã¦
ã説æã®éããã©ã¤ãã®å½±é¿ä¸ã«ããMovableãªMeshã¯ãã®ã¾ã¾å½±çæã®ã³ã¹ãã«ã¤ãªããã¾ããä»ã¾ã§ã®èª¬æã¯Point Lightã§è¡ãã¾ããããDirectional Lightã¯åºæ¬çã«ã·ã¼ã³å
¨ä½ã«å½±é¿ãåã¼ãã®ã§ããã§ã¯åé¡ã§ãããã®ããããããDirectional Lightã¯åºæ¬çã«ãå½±æç»ãCascade Shadow Mapã§è¡ãããã«ãã¦ãã¾ããã§ãã®ã§ãä¸è¨ã®ã·ã¼ã³ããããã¡ã¤ã«ããã¨ã«ã¹ã±ã¼ãã·ã£ãã¦ã«ãã£ã¦ã·ã¼ã³ãåå²(Split)ããã¦å½±æç»ããã¦ããã®ããããã¾ãã
ã§ãã®ã§ãæ®æ®µä½¿ããã¦ããéDirectional Lightã§Movableãªã¡ãã·ã¥ã«ããã³ã¹ãã ããæ°ã«ãªããã¨ã¯å°ãªãã¨æãã¾ããä¸å¿Cascade Shadowã®å¤ã®ãªãã¸ã§ã¯ãããã¤ã³ãã©ã¤ãã¨åãææ³ã«ãã£ã¦å½±æç»ãããªãã·ã§ã³ãããã¾ããCascade Shadow Mapã®è¨å®ã®Inset Shadows For Movable Objectsã§ãã
ãã¡ããè¨å®ããDynamic Shadow Distance Stationary Lightã®è·é¢ãå°ãããã¦å
¨ã¦ã®ãªãã¸ã§ã¯ããã«ã¹ã±ã¼ãã®å¤ã«åºãã¦ã¿ã¾ããããã¨ä¸è¨ã®ããã«ããªãã¸ã§ã¯ãæ¯ã«å½±æç»ç¨ã®ãã©ã¹ã¿ã ãä½æããããã¨ãè¦ã¦åãããã¨æãã¾ãã
ãããã¡ã¤ã«ãã¦ãåãªãã¸ã§ã¯ãã®ã·ã£ãã¦ã³ã¹ããçºçãã¦ããã®ããããã¾ãã
èªãã§ããã ããããã¨ããããã¾ãã
ã¾ã¨ããã¨ãStationary Lightãä½ãå½±ã¯ããã
- StaticãªMeshã®å ´åããã®ã·ã£ãã¦ãããã¯ï¼ã©ã¤ããããã¨åæ§ã«ï¼äºåã«è¨ç®ãããåMeshãæã¡ã¾ããã¬ã³ããªã³ã°æã¯ãã®å¤ãèªã¿è¾¼ãã ãã§å½±ã®å¤ããããã®ã§å¦çè² è·ã軽ãã§ãã
- MovableãªMeshã®å ´åããã®ã·ã£ãã¦ã¯Meshæ¯ã«åçã«è¨ç®ããã¾ãã沢山ã®MovableãªMeshãå½±é¿ãåããå ´åãMovable Lightã«ããã»ããå¦çã軽ããã¨ãããã¾ãã
ææ¥ã¯ãntaro@年末に向けて準備中 (@tarotarokun) | Twitterããã®ãC++ã使ã£ãSocketã使ã£ãéä¿¡å¨ãã®æ¸ãæ¹ã解説ããããã§ãã
éä¿¡å¨ãã®æ
å ±ãã©ãã©ãå
å®ãã¦ãã¦ã¦é常ã«ãããããã§ãï¼æ¥½ãã¿ã§ãï¼