SceneKitでふんわりした影を描画する/potatotips58

 SceneKitでふんわりした影を描画する/potatotips58

3e66b3ccfa617b78c59d9dec865aa29f?s=128

noppefoxwolf

January 28, 2019
Tweet

Transcript

  1. 4DFOF,JUͰ;ΜΘΓͨ͠ӨΛ࡞Δ QPUBUPUJQT 

  2. ϥΠϒ഑৴ΞϓϦ1PDPDIB IUUQTNFEJVNDPNQPDPDIBFOHJOFFSJOH 

  3. OPQQF !OPQQFGPYXPMG ! 1PDPDIBJ04ΤϯδχΞ " ͖ͭͶ͔Θ͍͍ # J04%$ͰඳըपΓͷ࿩Λͨ͠ $ ࠷ۙ"3ʹڵຯ͋Γ

    ϥΠϒ഑৴ΞϓϦ 
  4. J04͔ΒVTE[Λαϙʔτ VTE["QQMFͱ1JYFSͰڞಉ։ൃͨ͠%ϑΝΠϧϑΥʔ Ϛοτ 

  5. 

  6. 'JMFͰϓϨϏϡʔ΍ "3഑ஔ΋Մೳ 

  7. 'JMFͷϓϨϏϡʔͷ Өʹ஫໨὎ 

  8. 88%$Ͱ$POUBDU4IBEPXͱදݱ IUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXED UJNF 

  9. $POUBDU4IBEPXʢ઀ ৮Өʣͱ͸ ઀஍ײɾॏͳΓײΛग़ͨ͢Ίͷ΋ ͷ IUUQTUXJUUFSDPNVOSFBMFOHJOFKQTUBUVT  

  10. $POUBDU4IBEPX࢖ͬͯΈ͍ͨʂ 

  11. 4DFOF,JUͰӨΛ͚ͭͯΈΔ w 4$/-JHIUͷDBTUT4IBEPXΛ0/ʹ͢Δ w EJSFDUJPOBM͔ɺTQPUλΠϓΛ࢖͏ IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPOTDFOFLJUTDOMJHIU DBTUTTIBEPX 

  12. // ΦϒδΣΫτ let scene = SCNScene(named: "stratocaster.scn")! // ϥΠτ let

    light = SCNLight() light.type = .directional light.castsShadow = true let lightNode = SCNNode() lightNode.light = light // চ let floor = SCNFloor() ... 
  13. 4$/-JHIUͰ͸͸͖ͬΓͨ͠Өʹ ͳͬͯ͠·͏ɻ 

  14. ҰԠ4IEBPX3BEJVT΋͋Δ͕ɺϘ Χ͠ํ͕ࡶ lightNode.light!.shadowRadius = 16 lightNode.light!.shadowSampleCount = 16 

  15. άά͍ͬͯΔͱɺήʔϜͷهࣄ͕ώοτ IUUQCMPHTJNPOSPESJHVF[GSBSUJDMFTBGFXTDOUFDIOJRVFFYBNQMFTIUNM 

  16. TDSFFOTQBDFBNCJFOUPDDMVTJPO ෺ମ͕ۙ઀ͯ͠ڱ͘ͳͬͨͱ͜Ζ΍෦԰ͷ۱ͳͲʹɺपғͷޫʢ؀ڥ ޫʣ͕ःΒΕΔ͜ͱʹΑͬͯӨ͕ݱΕΔݱ৅ΛΞϯϏΤϯτɾΦΫ ϧʔδϣϯʢ؀ڥःṭ؀ڥด࠹ɺӳBNCJFOUPDDMVTJPOʣͱݺ Ϳɻ44"0͸%ը໘ͷϨϯμϦϯά݁ՌʹޙॲཧΛ͔͚ΔϙετΤ ϑΣΫτͷҰछͰ͋ΓɺٖࣅతͳϨϯμϦϯά݁Ռʹ௥Ճ͢Δ΋ͷͰ ͋Δɻ IUUQTKBXJLJQFEJBPSHXJLJ44"0 

  17. 44"0 camera?.screenSpaceAmbientOcclusionIntensity = 5 camera?.screenSpaceAmbientOcclusionNormalThreshold = 0.1 camera?.screenSpaceAmbientOcclusionDepthThreshold = 0.08

    camera?.screenSpaceAmbientOcclusionBias = 0.33 camera?.screenSpaceAmbientOcclusionRadius = 3.0 
  18. 

  19. ઀஍໘Ҏ֎ͷՕॴͷӨ΋͋Δ 

  20. ;ΜΘΓͨ͠Ө͸ࣗલͰඳը͠ͳ͍ ͱμϝͦ͏ 

  21. 4$/5FDIOJRVF w ϚϧνύεϨϯμϦϯάͷͨΊͷΫϥε ը໘̍ճͷߋ৽ͷؒʹɺҟͳΔγʔϯΛෳ਺ճϨϯ μϦϯάͯ͠߹੒ͨ݁͠ՌΛදࣔ͢Δػೳɻ .FUBM΍0QFO(-&4ͰγΣʔμΛॻ͘ࣄ͕ग़དྷΔɻ ೖྗʹγʔϯͷ৭৘ใ΍ਂ౓৘ใ͕࢖͑Δ 

  22. 

  23. ΍ͬͯΈͨ ΧϝϥΛೋͭ഑ஔͯ͠ɺԼ͔ΒͷೖྗΛਂ౓ʹม׵͠ ͯϒϥʔΛ͔͚Δɻ 

  24.  IUUQCMPHTJNPOSPESJHVF[GSBSUJDMFTBGFXTDOUFDIOJRVFFYBNQMFTIUNM 

  25. Ө͚ͩ࡞ͬͯΈͨ w Α͘ΈΔͱϞΞϨʢࣶ໛༷ʣ ͕ʜ w ͦ΋ͦ΋Χϝϥ୆ஔ͘ͷ͸ʜ w γΣʔμਅ໘໨ʹॻ͜͏ͱ͢Δ ͱαΫοͱग़དྷͳͦ͏ 

  26. ୅ସҊΛ୳͢ 

  27. HPCP 4$/-JHIUͷӨΛࣗલͷը૾Ͱඳ ը͢Δػೳ ӨΛൃࣹ͢ΔϥΠτ ϦΞϧλΠϜͰߋ৽͸ग़དྷͳ͍ 

  28. HPCP w 4$/5FDIOJRVFͰਂ౓ը૾ʹม׵ w 4$/7JFXͷTOBQTIPUͰ6**NBHFΛऔಘ w $*'JMUFSͰϒϥʔΛ͔͚Δ w 4$/-JHIUͷHPCPʹը૾Ληοτ 

  29. ݁Ռ 

  30. ՝୊ w Өͷೱ୶ͳͲ·ͩ'JMFͷදݱʹୡ͍ͯ͠ͳ͍ w 4$/5FDIOJRVFͰશͯ׬݁ग़དྷΔ͔΋ w TIBEFS.PEJpFSTͰϥΠςΟϯάγΣʔμ͕࿔ΕΔ 

  31. ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ