SlideShare ist ein Scribd-Unternehmen logo
1 von 38
Downloaden Sie, um offline zu lesen
GPU Instancing
Jean-François F Fortin
Graphics Expert, Field Engineer, Unity Technologies
jff@unity3d.com
Starting Point
• I started at Unity recently and I was looking for ideas to learn to use the
engine.
• Worked on many projects where we where limited in draw calls.
• Inspired by the work I’ve done for the Shinra Technologies ( ) cloud
gaming platform. More specifically:
• - Engine architecture focusing on “drawing many things”.
• - “Living World” demo.
Shinra Technology’s Living World Demo
Starting Point
• “Data oriented designs” to work well both on the CPU and GPU.
• CPU was potentially expensive as it was required to do specific tasks.
• GPU is cheap as work could be shared between multiple players.
• Same ideas can be adapted to current games:
• - Games can often be limited by the CPU.
• - GPU can often execute more work.
Starting Point
• What could I bring from this within unity as a learning project?
• I’ll take you through the mind of a graphics programmer, through my
experiments and thought process to optimize instancing.
Why Instancing?
• Game performance is currently usually limited by the CPU.
• The world is filled with things, games usually look empty by comparison.
• Examples:
• - Dense forest with many species of trees, cities filled with buildings.
• - Real world feels alive filled with different animals or people.
• Problems:
• - CPU not as powerful as GPUs.
• - Complex and dense scenes means lots of work on the CPU.
• - Most of the scene traversal is not GPU friendly.
First Steps… Learning Unity Instancing
• Instancing is typically used to render identical objects:
• - Same mesh.
• - Same material.
• - No animations.
• Helps to reduce the CPU usage as objects are grouped together and less
draw calls needs to be issued.
• Available on most platforms.
First Steps… Learning Unity Instancing
To enable instancing:
1. Create a new material.
2. Check “Enable Instancing”.
3. Done.
Demo: Unity’s GPU Instancing
• Custom Shader example:
First Steps… Per-Instance Data
First Steps… Per-Instance Data
• Custom Shader example:
First Steps… Per-Instance Data
• MaterialPropertyBlock
Analysis
• Renders faster than individual instances but still slow.
• Time spent on the CPU processing the scene.
• Solution?
• - Remove all the objects from the scene!
• - Literally!
GPU Instancing using
Graphics.DrawMeshInstancedIndirect(…)
Walking… Use scripts to tweak rendering
1. Remove objects (only need to disable the mesh renderers) from the
scene.
2. Create MaterialPropertyBlock to include any instance data.
3. Render instances using Graphics.DrawMeshInstancedIndirect(…) which
is a new addition to Unity 5.6.
Walking… Use scripts to tweak rendering
Analysis
• Better performance on the CPU.
• Can usually render more instances of the same model as the previous
test.
• GPU starts to have trouble when using more complex models.
• Solution?
• - GPU should do the visibility testing.
• - Feed the result into the Graphics.DrawMeshInstancedIndirect(…) call.
Running… Indirect calls
• Same as the regular calls in concept. Could in fact implement the
functionality of the regular call using them.
• Difference?
• - Takes the draw call parameters from a GPU buffer.
• - See Graphics.DrawProceduralIndirect
• - See Graphics.DrawMeshInstancedIndirect
• - See ComputeShader.DispatchIndirect
Running… Indirect calls
• Very useful to link work done on compute shader with regular rendering.
• No need to fetch the results back on CPU…
• - This could potentially have a huge latency issues…
• This enables the compute shaders to write the draw arguments.
• The GPU later reads from the buffer the draw arguments.
Running… Visibility Testing
• It can be very simple and cheap to do visibility testing on the GPU.
• Mostly dot products, and the GPU is fast at them.
• Let’s build a data oriented version of the scene…
• - A point cloud is the perfect structure for simple instances.
Running… Visibility Testing
Steps:
1. Shader process the objects and filters the visible objects.
2. Visible objects gets added into a “VisibleList” to be rendered.
3. Counter from the VisibleList is then used to update the buffer with the
draw arguments.
4. DrawMeshInstanceIndirect(…)
Running… Visibility Testing
Running… Instance Setup
Demo: Visibility testing
Analysis
• Best performances so far.
• Shader can be flexible on what can be rendered as instances
• Can even support dynamic and animated instances.
Ideas to push this further…
Animated Data
• Regular instancing won’t work with animated objects.
• Skinning is often done on the CPU or as a separate pass.
• - “Stream output” from geometry shader or compute shader.
• - In both cases it is essentially the same as having separate models for
each animated instances.
• Could re-implement skinning in Vertex Shader and store the matrices into
a buffer like we did for our other parameters…
• - This is a lot of data and could require a lot of VRAM.
• - Not straightforward to implement as the required information is not
easy to get.
Animated Data
Solution:
1. Bake animations as vertex animations and store the data into textures.
2. Set the animation texture as a property on the material.
3. Update the frame number and store along the other instance data.
Animated Data: Baking
Animated Data: Vertex Shader
Animated Data: Binding on Material
Moving Objects
• How could we extend this to support birds, little animals, etc.
• Compute shader that updates the data structure.
• Can have objects moving in the scene without hurting performance much.
1. Create a buffer containing “update commands”.
2. Compute Shader to process individual commands.
1. -> Update object #103 to position [100, 10, 500].
LODs and Billboards
• Use the shader to do the calculations to get which LOD to use.
• Create multiple draw calls from the buffer arguments (IndirectArgs) one
for each LOD.
• Billboards are essentially just a separate LOD.
Conclusions
• Unity instancing options are varied and work well.
• Can be improved using new features such as the indirect calls.
• Can go around limitations of instancing by using shader tricks.
Thank you!

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (18)

【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化
【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化
【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化
 
Game Engine Architecture
Game Engine ArchitectureGame Engine Architecture
Game Engine Architecture
 
Developing a Multiplayer RTS with the Unreal Engine 3
Developing a Multiplayer RTS with the Unreal Engine 3Developing a Multiplayer RTS with the Unreal Engine 3
Developing a Multiplayer RTS with the Unreal Engine 3
 
How we optimized our Game - Jake & Tess' Finding Monsters Adventure
How we optimized our Game - Jake & Tess' Finding Monsters AdventureHow we optimized our Game - Jake & Tess' Finding Monsters Adventure
How we optimized our Game - Jake & Tess' Finding Monsters Adventure
 
Unity Internals: Memory and Performance
Unity Internals: Memory and PerformanceUnity Internals: Memory and Performance
Unity Internals: Memory and Performance
 
[UniteKorea2013] Memory profiling in Unity
[UniteKorea2013] Memory profiling in Unity[UniteKorea2013] Memory profiling in Unity
[UniteKorea2013] Memory profiling in Unity
 
Mobile Performance Tuning: Poor Man's Tips And Tricks
Mobile Performance Tuning: Poor Man's Tips And TricksMobile Performance Tuning: Poor Man's Tips And Tricks
Mobile Performance Tuning: Poor Man's Tips And Tricks
 
【Unite 2017 Tokyo】Anima2Dについて語るで!2Dアニメーションの未来
【Unite 2017 Tokyo】Anima2Dについて語るで!2Dアニメーションの未来【Unite 2017 Tokyo】Anima2Dについて語るで!2Dアニメーションの未来
【Unite 2017 Tokyo】Anima2Dについて語るで!2Dアニメーションの未来
 
Design your 3d game engine
Design your 3d game engineDesign your 3d game engine
Design your 3d game engine
 
【Unite 2017 Tokyo】EditorVRの設計から学んだこと:使えるVRエディターのためのデザイン
【Unite 2017 Tokyo】EditorVRの設計から学んだこと:使えるVRエディターのためのデザイン【Unite 2017 Tokyo】EditorVRの設計から学んだこと:使えるVRエディターのためのデザイン
【Unite 2017 Tokyo】EditorVRの設計から学んだこと:使えるVRエディターのためのデザイン
 
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile GamesUnreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
 
Fast rendering with starling
Fast rendering with starlingFast rendering with starling
Fast rendering with starling
 
Unreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal EditorUnreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal Editor
 
Building Multiplayer Games (w/ Unity)
Building Multiplayer Games (w/ Unity)Building Multiplayer Games (w/ Unity)
Building Multiplayer Games (w/ Unity)
 
Optimizing Large Scenes in Unity
Optimizing Large Scenes in UnityOptimizing Large Scenes in Unity
Optimizing Large Scenes in Unity
 
Unreal Engine Basics 06 - Animation, Audio, Visual Effects
Unreal Engine Basics 06 - Animation, Audio, Visual EffectsUnreal Engine Basics 06 - Animation, Audio, Visual Effects
Unreal Engine Basics 06 - Animation, Audio, Visual Effects
 
【Unite Tokyo 2018】その最適化、本当に最適ですか!? ~正しい最適化を行うためのテクニック~
【Unite Tokyo 2018】その最適化、本当に最適ですか!? ~正しい最適化を行うためのテクニック~【Unite Tokyo 2018】その最適化、本当に最適ですか!? ~正しい最適化を行うためのテクニック~
【Unite Tokyo 2018】その最適化、本当に最適ですか!? ~正しい最適化を行うためのテクニック~
 
Optimization in Unity: simple tips for developing with "no surprises" / Anton...
Optimization in Unity: simple tips for developing with "no surprises" / Anton...Optimization in Unity: simple tips for developing with "no surprises" / Anton...
Optimization in Unity: simple tips for developing with "no surprises" / Anton...
 

Ähnlich wie 【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法

Ähnlich wie 【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法 (20)

Unity - Internals: memory and performance
Unity - Internals: memory and performanceUnity - Internals: memory and performance
Unity - Internals: memory and performance
 
Optimizing unity games (Google IO 2014)
Optimizing unity games (Google IO 2014)Optimizing unity games (Google IO 2014)
Optimizing unity games (Google IO 2014)
 
The Rise of Parallel Computing
The Rise of Parallel ComputingThe Rise of Parallel Computing
The Rise of Parallel Computing
 
0507 057 01 98 * Adana Cukurova Klima Servisleri
0507 057 01 98 * Adana Cukurova Klima Servisleri0507 057 01 98 * Adana Cukurova Klima Servisleri
0507 057 01 98 * Adana Cukurova Klima Servisleri
 
Optimizing mobile applications - Ian Dundore, Mark Harkness
Optimizing mobile applications - Ian Dundore, Mark HarknessOptimizing mobile applications - Ian Dundore, Mark Harkness
Optimizing mobile applications - Ian Dundore, Mark Harkness
 
Шлигін Олександр “Розробка ігор в Unity загальні помилки” GameDev Conference ...
Шлигін Олександр “Розробка ігор в Unity загальні помилки” GameDev Conference ...Шлигін Олександр “Розробка ігор в Unity загальні помилки” GameDev Conference ...
Шлигін Олександр “Розробка ігор в Unity загальні помилки” GameDev Conference ...
 
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
 
Profiling tools and Android Performance patterns
Profiling tools and Android Performance patternsProfiling tools and Android Performance patterns
Profiling tools and Android Performance patterns
 
Cardboard VR: Building Low Cost VR Experiences
Cardboard VR: Building Low Cost VR ExperiencesCardboard VR: Building Low Cost VR Experiences
Cardboard VR: Building Low Cost VR Experiences
 
Developing VR Experiences with Unity
Developing VR Experiences with UnityDeveloping VR Experiences with Unity
Developing VR Experiences with Unity
 
Improving Game Performance in the Browser
Improving Game Performance in the BrowserImproving Game Performance in the Browser
Improving Game Performance in the Browser
 
Building VR Applications For Google Cardboard
Building VR Applications For Google CardboardBuilding VR Applications For Google Cardboard
Building VR Applications For Google Cardboard
 
Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...
Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...
Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...
 
Developing Next-Generation Games with Stage3D (Molehill)
Developing Next-Generation Games with Stage3D (Molehill) Developing Next-Generation Games with Stage3D (Molehill)
Developing Next-Generation Games with Stage3D (Molehill)
 
WT-4069, WebCL: Enabling OpenCL Acceleration of Web Applications, by Mikael ...
WT-4069, WebCL: Enabling OpenCL Acceleration of Web Applications, by  Mikael ...WT-4069, WebCL: Enabling OpenCL Acceleration of Web Applications, by  Mikael ...
WT-4069, WebCL: Enabling OpenCL Acceleration of Web Applications, by Mikael ...
 
ConnectTheDots - My Galileo based weather station and first entry into IoT
ConnectTheDots - My Galileo based weather station and first entry into IoTConnectTheDots - My Galileo based weather station and first entry into IoT
ConnectTheDots - My Galileo based weather station and first entry into IoT
 
Practical SPU Programming in God of War III
Practical SPU Programming in God of War IIIPractical SPU Programming in God of War III
Practical SPU Programming in God of War III
 
Android performance
Android performanceAndroid performance
Android performance
 
Introduction to Computing on GPU
Introduction to Computing on GPUIntroduction to Computing on GPU
Introduction to Computing on GPU
 
Soc research
Soc researchSoc research
Soc research
 

Mehr von Unity Technologies Japan K.K.

Mehr von Unity Technologies Japan K.K. (20)

建築革命、更に更に進化!便利さ向上【Unity Reflect ver 3.0 】
建築革命、更に更に進化!便利さ向上【Unity Reflect ver 3.0 】建築革命、更に更に進化!便利さ向上【Unity Reflect ver 3.0 】
建築革命、更に更に進化!便利さ向上【Unity Reflect ver 3.0 】
 
UnityのクラッシュをBacktraceでデバッグしよう!
UnityのクラッシュをBacktraceでデバッグしよう!UnityのクラッシュをBacktraceでデバッグしよう!
UnityのクラッシュをBacktraceでデバッグしよう!
 
Unityで始めるバーチャルプロダクション
Unityで始めるバーチャルプロダクションUnityで始めるバーチャルプロダクション
Unityで始めるバーチャルプロダクション
 
ビジュアルスクリプティング (旧:Bolt) で始めるUnity入門3日目 ゲームをカスタマイズしよう
ビジュアルスクリプティング (旧:Bolt) で始めるUnity入門3日目 ゲームをカスタマイズしようビジュアルスクリプティング (旧:Bolt) で始めるUnity入門3日目 ゲームをカスタマイズしよう
ビジュアルスクリプティング (旧:Bolt) で始めるUnity入門3日目 ゲームをカスタマイズしよう
 
ビジュアルスクリプティングで始めるUnity入門2日目 ゴールとスコアの仕組み - Unityステーション
ビジュアルスクリプティングで始めるUnity入門2日目 ゴールとスコアの仕組み - Unityステーションビジュアルスクリプティングで始めるUnity入門2日目 ゴールとスコアの仕組み - Unityステーション
ビジュアルスクリプティングで始めるUnity入門2日目 ゴールとスコアの仕組み - Unityステーション
 
ビジュアルスクリプティングで始めるUnity入門1日目 プレイヤーを動かそう
ビジュアルスクリプティングで始めるUnity入門1日目 プレイヤーを動かそうビジュアルスクリプティングで始めるUnity入門1日目 プレイヤーを動かそう
ビジュアルスクリプティングで始めるUnity入門1日目 プレイヤーを動かそう
 
PlasticSCMの活用テクニックをハンズオンで一緒に学ぼう!
PlasticSCMの活用テクニックをハンズオンで一緒に学ぼう!PlasticSCMの活用テクニックをハンズオンで一緒に学ぼう!
PlasticSCMの活用テクニックをハンズオンで一緒に学ぼう!
 
点群を使いこなせ! 可視化なんて当たり前、xRと点群を組み合わせたUnityの世界 【Interact , Stipple】
点群を使いこなせ! 可視化なんて当たり前、xRと点群を組み合わせたUnityの世界 【Interact , Stipple】点群を使いこなせ! 可視化なんて当たり前、xRと点群を組み合わせたUnityの世界 【Interact , Stipple】
点群を使いこなせ! 可視化なんて当たり前、xRと点群を組み合わせたUnityの世界 【Interact , Stipple】
 
Unity教える先生方注目!ティーチャートレーニングデイを体験しよう
Unity教える先生方注目!ティーチャートレーニングデイを体験しようUnity教える先生方注目!ティーチャートレーニングデイを体験しよう
Unity教える先生方注目!ティーチャートレーニングデイを体験しよう
 
「原神」におけるコンソールプラットフォーム開発
「原神」におけるコンソールプラットフォーム開発「原神」におけるコンソールプラットフォーム開発
「原神」におけるコンソールプラットフォーム開発
 
FANTASIANの明日使えない特殊テクニック教えます
FANTASIANの明日使えない特殊テクニック教えますFANTASIANの明日使えない特殊テクニック教えます
FANTASIANの明日使えない特殊テクニック教えます
 
インディーゲーム開発の現状と未来 2021
インディーゲーム開発の現状と未来 2021インディーゲーム開発の現状と未来 2021
インディーゲーム開発の現状と未来 2021
 
建築革命、更に進化!デジタルツイン基盤の真打ち登場【概要編 Unity Reflect ver 2.1 】
建築革命、更に進化!デジタルツイン基盤の真打ち登場【概要編 Unity Reflect ver 2.1 】建築革命、更に進化!デジタルツイン基盤の真打ち登場【概要編 Unity Reflect ver 2.1 】
建築革命、更に進化!デジタルツイン基盤の真打ち登場【概要編 Unity Reflect ver 2.1 】
 
Burstを使ってSHA-256のハッシュ計算を高速に行う話
Burstを使ってSHA-256のハッシュ計算を高速に行う話Burstを使ってSHA-256のハッシュ計算を高速に行う話
Burstを使ってSHA-256のハッシュ計算を高速に行う話
 
Cinemachineで見下ろし視点のカメラを作る
Cinemachineで見下ろし視点のカメラを作るCinemachineで見下ろし視点のカメラを作る
Cinemachineで見下ろし視点のカメラを作る
 
徹底解説 Unity Reflect【開発編 ver2.0】
徹底解説 Unity Reflect【開発編 ver2.0】徹底解説 Unity Reflect【開発編 ver2.0】
徹底解説 Unity Reflect【開発編 ver2.0】
 
徹底解説 Unity Reflect【概要編 ver2.0】
徹底解説 Unity Reflect【概要編 ver2.0】徹底解説 Unity Reflect【概要編 ver2.0】
徹底解説 Unity Reflect【概要編 ver2.0】
 
Unityティーチャートレーニングデイ -認定プログラマー編-
Unityティーチャートレーニングデイ -認定プログラマー編-Unityティーチャートレーニングデイ -認定プログラマー編-
Unityティーチャートレーニングデイ -認定プログラマー編-
 
Unityティーチャートレーニングデイ -認定3Dアーティスト編-
Unityティーチャートレーニングデイ -認定3Dアーティスト編-Unityティーチャートレーニングデイ -認定3Dアーティスト編-
Unityティーチャートレーニングデイ -認定3Dアーティスト編-
 
Unityティーチャートレーニングデイ -認定アソシエイト編-
Unityティーチャートレーニングデイ -認定アソシエイト編-Unityティーチャートレーニングデイ -認定アソシエイト編-
Unityティーチャートレーニングデイ -認定アソシエイト編-
 

Kürzlich hochgeladen

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 

【Unite 2017 Tokyo】インスタンシングを用いた美麗なグラフィックの実現方法

  • 1.
  • 3. Jean-François F Fortin Graphics Expert, Field Engineer, Unity Technologies jff@unity3d.com
  • 4. Starting Point • I started at Unity recently and I was looking for ideas to learn to use the engine. • Worked on many projects where we where limited in draw calls. • Inspired by the work I’ve done for the Shinra Technologies ( ) cloud gaming platform. More specifically: • - Engine architecture focusing on “drawing many things”. • - “Living World” demo.
  • 6. Starting Point • “Data oriented designs” to work well both on the CPU and GPU. • CPU was potentially expensive as it was required to do specific tasks. • GPU is cheap as work could be shared between multiple players. • Same ideas can be adapted to current games: • - Games can often be limited by the CPU. • - GPU can often execute more work.
  • 7. Starting Point • What could I bring from this within unity as a learning project? • I’ll take you through the mind of a graphics programmer, through my experiments and thought process to optimize instancing.
  • 8. Why Instancing? • Game performance is currently usually limited by the CPU. • The world is filled with things, games usually look empty by comparison. • Examples: • - Dense forest with many species of trees, cities filled with buildings. • - Real world feels alive filled with different animals or people. • Problems: • - CPU not as powerful as GPUs. • - Complex and dense scenes means lots of work on the CPU. • - Most of the scene traversal is not GPU friendly.
  • 9. First Steps… Learning Unity Instancing • Instancing is typically used to render identical objects: • - Same mesh. • - Same material. • - No animations. • Helps to reduce the CPU usage as objects are grouped together and less draw calls needs to be issued. • Available on most platforms.
  • 10. First Steps… Learning Unity Instancing To enable instancing: 1. Create a new material. 2. Check “Enable Instancing”. 3. Done.
  • 11. Demo: Unity’s GPU Instancing
  • 12. • Custom Shader example: First Steps… Per-Instance Data
  • 13. First Steps… Per-Instance Data • Custom Shader example:
  • 14. First Steps… Per-Instance Data • MaterialPropertyBlock
  • 15. Analysis • Renders faster than individual instances but still slow. • Time spent on the CPU processing the scene. • Solution? • - Remove all the objects from the scene! • - Literally!
  • 17. Walking… Use scripts to tweak rendering 1. Remove objects (only need to disable the mesh renderers) from the scene. 2. Create MaterialPropertyBlock to include any instance data. 3. Render instances using Graphics.DrawMeshInstancedIndirect(…) which is a new addition to Unity 5.6.
  • 18. Walking… Use scripts to tweak rendering
  • 19. Analysis • Better performance on the CPU. • Can usually render more instances of the same model as the previous test. • GPU starts to have trouble when using more complex models. • Solution? • - GPU should do the visibility testing. • - Feed the result into the Graphics.DrawMeshInstancedIndirect(…) call.
  • 20. Running… Indirect calls • Same as the regular calls in concept. Could in fact implement the functionality of the regular call using them. • Difference? • - Takes the draw call parameters from a GPU buffer. • - See Graphics.DrawProceduralIndirect • - See Graphics.DrawMeshInstancedIndirect • - See ComputeShader.DispatchIndirect
  • 21. Running… Indirect calls • Very useful to link work done on compute shader with regular rendering. • No need to fetch the results back on CPU… • - This could potentially have a huge latency issues… • This enables the compute shaders to write the draw arguments. • The GPU later reads from the buffer the draw arguments.
  • 22. Running… Visibility Testing • It can be very simple and cheap to do visibility testing on the GPU. • Mostly dot products, and the GPU is fast at them. • Let’s build a data oriented version of the scene… • - A point cloud is the perfect structure for simple instances.
  • 23. Running… Visibility Testing Steps: 1. Shader process the objects and filters the visible objects. 2. Visible objects gets added into a “VisibleList” to be rendered. 3. Counter from the VisibleList is then used to update the buffer with the draw arguments. 4. DrawMeshInstanceIndirect(…)
  • 27. Analysis • Best performances so far. • Shader can be flexible on what can be rendered as instances • Can even support dynamic and animated instances.
  • 28. Ideas to push this further…
  • 29. Animated Data • Regular instancing won’t work with animated objects. • Skinning is often done on the CPU or as a separate pass. • - “Stream output” from geometry shader or compute shader. • - In both cases it is essentially the same as having separate models for each animated instances. • Could re-implement skinning in Vertex Shader and store the matrices into a buffer like we did for our other parameters… • - This is a lot of data and could require a lot of VRAM. • - Not straightforward to implement as the required information is not easy to get.
  • 30. Animated Data Solution: 1. Bake animations as vertex animations and store the data into textures. 2. Set the animation texture as a property on the material. 3. Update the frame number and store along the other instance data.
  • 33. Animated Data: Binding on Material
  • 34. Moving Objects • How could we extend this to support birds, little animals, etc. • Compute shader that updates the data structure. • Can have objects moving in the scene without hurting performance much. 1. Create a buffer containing “update commands”. 2. Compute Shader to process individual commands. 1. -> Update object #103 to position [100, 10, 500].
  • 35. LODs and Billboards • Use the shader to do the calculations to get which LOD to use. • Create multiple draw calls from the buffer arguments (IndirectArgs) one for each LOD. • Billboards are essentially just a separate LOD.
  • 36. Conclusions • Unity instancing options are varied and work well. • Can be improved using new features such as the indirect calls. • Can go around limitations of instancing by using shader tricks.
  • 37.