SlideShare une entreprise Scribd logo
1  sur  38
Télécharger pour lire hors ligne
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!

Contenu connexe

Tendances

Tendances (18)

Practical Guide for Optimizing Unity on Mobiles
Practical Guide for Optimizing Unity on MobilesPractical Guide for Optimizing Unity on Mobiles
Practical Guide for Optimizing Unity on Mobiles
 
【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化
【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化
【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化
 
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
 
Game Engine Architecture
Game Engine ArchitectureGame Engine Architecture
Game Engine Architecture
 
Building Multiplayer Games (w/ Unity)
Building Multiplayer Games (w/ Unity)Building Multiplayer Games (w/ Unity)
Building Multiplayer Games (w/ Unity)
 
【Unite 2017 Tokyo】EditorVRの設計から学んだこと:使えるVRエディターのためのデザイン
【Unite 2017 Tokyo】EditorVRの設計から学んだこと:使えるVRエディターのためのデザイン【Unite 2017 Tokyo】EditorVRの設計から学んだこと:使えるVRエディターのためのデザイン
【Unite 2017 Tokyo】EditorVRの設計から学んだこと:使えるVRエディターのためのデザイン
 
【Unite Tokyo 2018】その最適化、本当に最適ですか!? ~正しい最適化を行うためのテクニック~
【Unite Tokyo 2018】その最適化、本当に最適ですか!? ~正しい最適化を行うためのテクニック~【Unite Tokyo 2018】その最適化、本当に最適ですか!? ~正しい最適化を行うためのテクニック~
【Unite Tokyo 2018】その最適化、本当に最適ですか!? ~正しい最適化を行うためのテクニック~
 
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
 
Game development -session on unity 3d
Game development -session on unity 3d Game development -session on unity 3d
Game development -session on unity 3d
 
Optimizing unity games (Google IO 2014)
Optimizing unity games (Google IO 2014)Optimizing unity games (Google IO 2014)
Optimizing unity games (Google IO 2014)
 
【Unite 2017 Tokyo】Anima2Dについて語るで!2Dアニメーションの未来
【Unite 2017 Tokyo】Anima2Dについて語るで!2Dアニメーションの未来【Unite 2017 Tokyo】Anima2Dについて語るで!2Dアニメーションの未来
【Unite 2017 Tokyo】Anima2Dについて語るで!2Dアニメーションの未来
 
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
 
Design your 3d game engine
Design your 3d game engineDesign your 3d game engine
Design your 3d game engine
 
Game Engine for Serious Games
Game Engine for Serious GamesGame Engine for Serious Games
Game Engine for Serious Games
 
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック(note付き)
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック(note付き)【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック(note付き)
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック(note付き)
 
Fast rendering with starling
Fast rendering with starlingFast rendering with starling
Fast rendering with starling
 
Optimizing Unity games for mobile devices
Optimizing Unity games for mobile devicesOptimizing Unity games for mobile devices
Optimizing Unity games for mobile devices
 
Whats new in Feathers 3.0?
Whats new in Feathers 3.0?Whats new in Feathers 3.0?
Whats new in Feathers 3.0?
 

En vedette

En vedette (13)

Unite2014: Mastering Physically Based Shading in Unity 5
Unite2014: Mastering Physically Based Shading in Unity 5Unite2014: Mastering Physically Based Shading in Unity 5
Unite2014: Mastering Physically Based Shading in Unity 5
 
【Unite 2017 Tokyo】Unityで楽しむノンフォトリアルな絵づくり講座:トゥーンシェーダー・マニアクス
【Unite 2017 Tokyo】Unityで楽しむノンフォトリアルな絵づくり講座:トゥーンシェーダー・マニアクス【Unite 2017 Tokyo】Unityで楽しむノンフォトリアルな絵づくり講座:トゥーンシェーダー・マニアクス
【Unite 2017 Tokyo】Unityで楽しむノンフォトリアルな絵づくり講座:トゥーンシェーダー・マニアクス
 
【Unite 2017 Tokyo】シェーダープログラミング入門!カスタムシェーダー、作るで!
【Unite 2017 Tokyo】シェーダープログラミング入門!カスタムシェーダー、作るで!【Unite 2017 Tokyo】シェーダープログラミング入門!カスタムシェーダー、作るで!
【Unite 2017 Tokyo】シェーダープログラミング入門!カスタムシェーダー、作るで!
 
【Unity道場スペシャル 2017大阪】カッコいい文字を使おう、そうText meshならね
【Unity道場スペシャル 2017大阪】カッコいい文字を使おう、そうText meshならね【Unity道場スペシャル 2017大阪】カッコいい文字を使おう、そうText meshならね
【Unity道場スペシャル 2017大阪】カッコいい文字を使おう、そうText meshならね
 
【Unity道場 2017】ゲーム開発者のためのタイポグラフィ講座
【Unity道場 2017】ゲーム開発者のためのタイポグラフィ講座【Unity道場 2017】ゲーム開発者のためのタイポグラフィ講座
【Unity道場 2017】ゲーム開発者のためのタイポグラフィ講座
 
【Unity道場 2017】伝える!伝わる!フォント表現入門
【Unity道場 2017】伝える!伝わる!フォント表現入門【Unity道場 2017】伝える!伝わる!フォント表現入門
【Unity道場 2017】伝える!伝わる!フォント表現入門
 
【Unite 2017 Tokyo】スマートフォンでどこまでできる?3Dゲームをぐりぐり動かすテクニック講座
【Unite 2017 Tokyo】スマートフォンでどこまでできる?3Dゲームをぐりぐり動かすテクニック講座【Unite 2017 Tokyo】スマートフォンでどこまでできる?3Dゲームをぐりぐり動かすテクニック講座
【Unite 2017 Tokyo】スマートフォンでどこまでできる?3Dゲームをぐりぐり動かすテクニック講座
 
【Unity道場スペシャル 2017博多】TextMesh Pro を使いこなす
【Unity道場スペシャル 2017博多】TextMesh Pro を使いこなす【Unity道場スペシャル 2017博多】TextMesh Pro を使いこなす
【Unity道場スペシャル 2017博多】TextMesh Pro を使いこなす
 
【Unity】今日から使えるTimeline
【Unity】今日から使えるTimeline【Unity】今日から使えるTimeline
【Unity】今日から使えるTimeline
 
【Unity道場 2017】PlayMakerによる初めてのUnityプログラミング
【Unity道場 2017】PlayMakerによる初めてのUnityプログラミング【Unity道場 2017】PlayMakerによる初めてのUnityプログラミング
【Unity道場 2017】PlayMakerによる初めてのUnityプログラミング
 
【Unity道場スペシャル 2017博多】Unityで楽しむノンフォトリアルな絵づくり講座:トゥーンシェーダー・マニアクス
【Unity道場スペシャル 2017博多】Unityで楽しむノンフォトリアルな絵づくり講座:トゥーンシェーダー・マニアクス【Unity道場スペシャル 2017博多】Unityで楽しむノンフォトリアルな絵づくり講座:トゥーンシェーダー・マニアクス
【Unity道場スペシャル 2017博多】Unityで楽しむノンフォトリアルな絵づくり講座:トゥーンシェーダー・マニアクス
 
【Unite 2017 Tokyo】Navmesh完全マスターへの道
【Unite 2017 Tokyo】Navmesh完全マスターへの道【Unite 2017 Tokyo】Navmesh完全マスターへの道
【Unite 2017 Tokyo】Navmesh完全マスターへの道
 
【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ
【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ
【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ
 

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

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

Unity - Internals: memory and performance
Unity - Internals: memory and performanceUnity - Internals: memory and performance
Unity - Internals: memory and performance
 
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
 
Шлигін Олександр “Розробка ігор в 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 ...
 
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...
 
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
 
DIY Java Profiling
DIY Java ProfilingDIY Java Profiling
DIY Java Profiling
 

Plus de Unite2017Tokyo

Plus de Unite2017Tokyo (20)

【Unite 2017 Tokyo】VRで探り,活用する,人の知覚の仕組み
【Unite 2017 Tokyo】VRで探り,活用する,人の知覚の仕組み【Unite 2017 Tokyo】VRで探り,活用する,人の知覚の仕組み
【Unite 2017 Tokyo】VRで探り,活用する,人の知覚の仕組み
 
【Unite 2017 Tokyo】スマートフォンゲーム「夢幻のラビリズ」開発秘話と動画・サウンドミドルウェアの使い処
【Unite 2017 Tokyo】スマートフォンゲーム「夢幻のラビリズ」開発秘話と動画・サウンドミドルウェアの使い処【Unite 2017 Tokyo】スマートフォンゲーム「夢幻のラビリズ」開発秘話と動画・サウンドミドルウェアの使い処
【Unite 2017 Tokyo】スマートフォンゲーム「夢幻のラビリズ」開発秘話と動画・サウンドミドルウェアの使い処
 
【Unite 2017 Tokyo】Virtual Design and Construction + AR/VR ~建築におけるUnity活用事例~
【Unite 2017 Tokyo】Virtual Design and Construction + AR/VR ~建築におけるUnity活用事例~【Unite 2017 Tokyo】Virtual Design and Construction + AR/VR ~建築におけるUnity活用事例~
【Unite 2017 Tokyo】Virtual Design and Construction + AR/VR ~建築におけるUnity活用事例~
 
【Unite 2017 Tokyo】2017年の注目アセット100連発
【Unite 2017 Tokyo】2017年の注目アセット100連発【Unite 2017 Tokyo】2017年の注目アセット100連発
【Unite 2017 Tokyo】2017年の注目アセット100連発
 
【Unite 2017 Tokyo】VR MAGIC! ~キャラクターに命を吹き込んだこの4年間の記録~
【Unite 2017 Tokyo】VR MAGIC! ~キャラクターに命を吹き込んだこの4年間の記録~【Unite 2017 Tokyo】VR MAGIC! ~キャラクターに命を吹き込んだこの4年間の記録~
【Unite 2017 Tokyo】VR MAGIC! ~キャラクターに命を吹き込んだこの4年間の記録~
 
【Unite 2017 Tokyo】Unity+WebGLでゲームを開発・運用して見えてきたメリット・デメリット
【Unite 2017 Tokyo】Unity+WebGLでゲームを開発・運用して見えてきたメリット・デメリット【Unite 2017 Tokyo】Unity+WebGLでゲームを開発・運用して見えてきたメリット・デメリット
【Unite 2017 Tokyo】Unity+WebGLでゲームを開発・運用して見えてきたメリット・デメリット
 
【Unite 2017 Tokyo】“Game Jam x VR x Unity”『Dead Hungry』のレシピ
【Unite 2017 Tokyo】“Game Jam x VR x Unity”『Dead Hungry』のレシピ【Unite 2017 Tokyo】“Game Jam x VR x Unity”『Dead Hungry』のレシピ
【Unite 2017 Tokyo】“Game Jam x VR x Unity”『Dead Hungry』のレシピ
 
【Unite 2017 Tokyo】「オルタナティブガールズ」〜50cmの距離感で3D美少女を最高にかわいく魅せる方法〜
【Unite 2017 Tokyo】「オルタナティブガールズ」〜50cmの距離感で3D美少女を最高にかわいく魅せる方法〜【Unite 2017 Tokyo】「オルタナティブガールズ」〜50cmの距離感で3D美少女を最高にかわいく魅せる方法〜
【Unite 2017 Tokyo】「オルタナティブガールズ」〜50cmの距離感で3D美少女を最高にかわいく魅せる方法〜
 
【Unite 2017 Tokyo】Unityで出来る『見える開発』のススメ 〜スマホゲーム「ららマジ」開発事例〜
【Unite 2017 Tokyo】Unityで出来る『見える開発』のススメ 〜スマホゲーム「ららマジ」開発事例〜【Unite 2017 Tokyo】Unityで出来る『見える開発』のススメ 〜スマホゲーム「ららマジ」開発事例〜
【Unite 2017 Tokyo】Unityで出来る『見える開発』のススメ 〜スマホゲーム「ららマジ」開発事例〜
 
【Unite 2017 Tokyo】Unityを使ったNintendo Switch™ローンチタイトル制作~スーパーボンバーマンRの事例~
【Unite 2017 Tokyo】Unityを使ったNintendo Switch™ローンチタイトル制作~スーパーボンバーマンRの事例~【Unite 2017 Tokyo】Unityを使ったNintendo Switch™ローンチタイトル制作~スーパーボンバーマンRの事例~
【Unite 2017 Tokyo】Unityを使ったNintendo Switch™ローンチタイトル制作~スーパーボンバーマンRの事例~
 
【Unite 2017 Tokyo】Nintendo Switch™ 本体同時発売必達、家庭用向けRPG「いけにえと雪のセツナ」開発の裏側
【Unite 2017 Tokyo】Nintendo Switch™ 本体同時発売必達、家庭用向けRPG「いけにえと雪のセツナ」開発の裏側【Unite 2017 Tokyo】Nintendo Switch™ 本体同時発売必達、家庭用向けRPG「いけにえと雪のセツナ」開発の裏側
【Unite 2017 Tokyo】Nintendo Switch™ 本体同時発売必達、家庭用向けRPG「いけにえと雪のセツナ」開発の裏側
 
【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ
【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ
【Unite 2017 Tokyo】もっと気軽に、動的なコンテンツ配信を ~アセットバンドルの未来と開発ロードマップ
 
【Unite 2017 Tokyo】新アセットバンドルツール詳解:アセット設定とアセットバンドルのワークフローを簡単に
【Unite 2017 Tokyo】新アセットバンドルツール詳解:アセット設定とアセットバンドルのワークフローを簡単に【Unite 2017 Tokyo】新アセットバンドルツール詳解:アセット設定とアセットバンドルのワークフローを簡単に
【Unite 2017 Tokyo】新アセットバンドルツール詳解:アセット設定とアセットバンドルのワークフローを簡単に
 
【Unite 2017 Tokyo】3次元CAD VR化最速ツールの秘密
【Unite 2017 Tokyo】3次元CAD VR化最速ツールの秘密【Unite 2017 Tokyo】3次元CAD VR化最速ツールの秘密
【Unite 2017 Tokyo】3次元CAD VR化最速ツールの秘密
 
【Unite 2017 Tokyo】WebGL:ゲームプラットフォームとしてのWebと現在と未来
【Unite 2017 Tokyo】WebGL:ゲームプラットフォームとしてのWebと現在と未来【Unite 2017 Tokyo】WebGL:ゲームプラットフォームとしてのWebと現在と未来
【Unite 2017 Tokyo】WebGL:ゲームプラットフォームとしてのWebと現在と未来
 
【Unite 2017 Tokyo】Unityライティング最新情報
【Unite 2017 Tokyo】Unityライティング最新情報【Unite 2017 Tokyo】Unityライティング最新情報
【Unite 2017 Tokyo】Unityライティング最新情報
 
【Unite 2017 Tokyo】スマホゲーム開発者なら知っておくべきチートのリスク&対策
【Unite 2017 Tokyo】スマホゲーム開発者なら知っておくべきチートのリスク&対策【Unite 2017 Tokyo】スマホゲーム開発者なら知っておくべきチートのリスク&対策
【Unite 2017 Tokyo】スマホゲーム開発者なら知っておくべきチートのリスク&対策
 
【Unite 2017 Tokyo】VIVEとUnityで、1週間で作る漫才VR
【Unite 2017 Tokyo】VIVEとUnityで、1週間で作る漫才VR【Unite 2017 Tokyo】VIVEとUnityで、1週間で作る漫才VR
【Unite 2017 Tokyo】VIVEとUnityで、1週間で作る漫才VR
 
【Unite 2017 Tokyo】DIYエフェクト実装: エンジニアレスでエフェクトを組み込める環境づくり
【Unite 2017 Tokyo】DIYエフェクト実装: エンジニアレスでエフェクトを組み込める環境づくり【Unite 2017 Tokyo】DIYエフェクト実装: エンジニアレスでエフェクトを組み込める環境づくり
【Unite 2017 Tokyo】DIYエフェクト実装: エンジニアレスでエフェクトを組み込める環境づくり
 
【Unite 2017 Tokyo】VRコンテンツを気持ちよくプレイさせるためのUI実装ガイド
【Unite 2017 Tokyo】VRコンテンツを気持ちよくプレイさせるためのUI実装ガイド【Unite 2017 Tokyo】VRコンテンツを気持ちよくプレイさせるためのUI実装ガイド
【Unite 2017 Tokyo】VRコンテンツを気持ちよくプレイさせるためのUI実装ガイド
 

Dernier

Dernier (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
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...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

【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.