yotiky Tech Blog

とあるエンジニアの備忘録

Mixed Reality Dev Days 「MRTK Performance Tools」セッション

スライドを機械翻訳通したので残しておく。
何枚か抜けてそうだけど。


f:id:yotiky:20200522081218j:plain

With the MRTK Omtimize Window. verify your Unity.

MRTK Omtimize Windowを使用して、あなたのUnityを確認してください。


f:id:yotiky:20200522081224p:plain

Perform a "coarse" profile of your app using the MRTK Visual Profiler.

Or the Windows Device Portal Frame Rate Counter.

Not using the MRTK? The Visual Profiler is a single "drop in" file.

MRTK Visual Profilerを使用してアプリの「粗い」プロファイルを実行します。

またはWindows Device Portal Frame Rate Counterを使用して、アプリの「粗い」プロファイルを実行します。

MRTKを使用していない場合 Visual Profilerは1つの "ドロップイン "ファイルです。


f:id:yotiky:20200522081230p:plain

Perform a "deep" profile of your app using:

- Unity's Profiler
- Visual Studio's Performance Profilers
- Windows Performance Analyzer

次を使用してアプリの「深い」プロファイルを実行します。

  • UnityのProfiler
  • Visual Stduioのパフォーマンス・プロファイラー
  • Windowsパフォーマンスアナライザ

f:id:yotiky:20200522081236p:plain

MRTK profiler markers! upcoming in MRTK 2.4.

MRTKプロファイラーマーカー!MRTK 2.4でアップグレードされます。


f:id:yotiky:20200522081248p:plain

My app is CPU bound, what do I do?

- Identify expensive code with Unity's CPU Usage profiler
- Look for "hitches" or long operations blocking the main thread
- Limit CPU-to-GPU interop
    - Limit draw calls, batch whenever possible
    - Avoid per frame resource creation

See Lars Simkins' talk "Leanings from the MR Surfaces app" on how to offload work from the main thread.

私のアプリはCPUに縛られていますが、どうすればいいですか?

  • UnityのCPU使用率プロファイラで高価なコードを特定する
  • メインスレッドをブロックしている "ヒッチ "や長い操作を探してください。
  • CPUからGPUへの相互接続を制限する
    • ドローコールを制限し、可能な限りバッチ処理
    • フレームごとのリソース作成を避ける

メインスレッドから作業をオフロードする方法については、Lars Simkins氏のトーク「MR Surfaces appからのLeanings」を参照してください。


f:id:yotiky:20200522081254p:plain

My app is GPU bound, what do I do?

Slow when hologram fills view?

- Simplify shaders (more on this later)
- Limit overdraw, use transparency sparingly, or other culling methods

Slow when whole scene in view?

- reduce model complexity
- Use LOD chains

私のアプリはGPUバインドされていますが、どうすればいいですか?
ホログラムがビューを埋め尽くすと遅くなりますか?

  • シェーダーを簡素化する(これについては後で詳しく説明します
  • オーバードローを制限する、透明度を控えめに使用する、または他のカリング方法

全体のシーンが表示されているときにスロー?

  • モデルの複雑さを軽減
  • LODチェーンを使用する

f:id:yotiky:20200522081300p:plain

Need detailed render state inspection?

Use Unity's Frame Debugger or check out RenderDoc.

詳細なレンダリング状態の検査が必要ですか?

Unityのフレームデバッガを使用するか、RenderDocをチェックしてください。


f:id:yotiky:20200522081307p:plain

Common performance pitfalls we see:

- Using the Unity standard shader, rather than MRTK Standard or Unlit shader. (GPU)
- Complex models, limit to < 100k vertices for most scenes. (GPU)
- Too many draw calls. (CPU &GPU)
- Overuse of transparency. (GPU)
- Constantly running services, such as spatial mapping. (CPU)
- Use of anti aliasing. (GPU)
- Using dynamic shadows. (CPU &GPU)
- Querying the Unity object hierarchy. (CPU)
- Use of post processing effects. (GPU)
- Large textures, or many texture samples per pixel. (GPU)
- Many per frame allocations. (CPU)

私たちが見ているよくあるパフォーマンスの落とし穴

  • MRTK標準シェーダやUnlitシェーダではなく、Unity標準シェーダを使用すること。(GPU)
  • 複雑なモデル、ほとんどのシーンで100k頂点以下に制限。(GPU)
  • ドローコールが多すぎる。(CPU &GPU)
  • 透明度の使いすぎ。(GPU)
  • 空間マッピングなどのサービスを常時実行していること。(CPU)
  • アンチエイリアシングの使用。(GPU)
  • ダイナミックシャドウを使う。(CPU &GPU)
  • Unityオブジェクトの階層を取得します。(CPU)
  • 後処理エフェクトの使用。(GPU)
  • 大きなテクスチャ、または1ピクセルあたりのテクスチャサンプル数が多い。(GPU)
  • フレームごとの割り当てが多い。(CPU)

f:id:yotiky:20200522081313p:plain

The MRTK Standard shading system is an "uber" shader that can:

- Achieve Visuals similar to Unity's Standard Shader
- Implement Fluent Design System principles
- Remain performance on Mixed Reality devices

MRTKスタンダードのシェーディングシステムは、それができる "uber "シェーダーです。

  • UnityのStandard Shaderと同様のビジュアルを実現します。
  • Fluent Design Systemの原理を実装する
  • Mixed Realityデバイスでのパフォーマンスを維持

f:id:yotiky:20200522081320p:plain

What can the MRTK Standard shading system already do?

MRTK標準のシェーディングシステムでは、すでに何ができるのでしょうか?


f:id:yotiky:20200522081326p:plain

The MRTK Standard shader users a simple approximation for lighting.

Because this shader does not calculate for physical correctness and energy conservation, it renders quickly and efficiently.

MRTK標準のシェーダを使用すると、照明のための簡単な近似値を使用することができます。

このシェーダは物理的な正確性や省エネルギーのための計算を行わないため、迅速かつ効率的にレンダリングを行うことができます。


f:id:yotiky:20200522081332p:plain

The MRTK Standard shading system contains many features available to the developer as series of checkboxes.

- Each option has a tool tip and many options contain documentation online

MRTK標準のシェーディングシステムには、開発者がチェックボックスとして利用できる多くの機能が含まれています。

  • 各オプションにはツールチップがあり、多くのオプションにはオンラインでのドキュメントが含まれています。

f:id:yotiky:20200522081338p:plain

Depth offset (Depth Bias)

- Can fix z-fighting when other options aren't available
- Forces one polygon to be drawn on top of another even if in the same position
- Available under the "Custom" Rendering Mode options

デプスオフセット(デプスバイアス

  • 他のオプションが利用できない場合に、Z-Fightingを修正することができます。
  • 同じ位置にあっても、あるポリゴンが別のポリゴンの上に描画されるように強制します。
  • カスタム」レンダリングモードオプションで利用可能

f:id:yotiky:20200522081344p:plain

Clipping Primitive Fade

- By default clipping primitives clip pixels on or off
- Transparent materials can have a clip "falloff"
- Defaults to 1-unit falloff, can be adjusted via "Blended Clipping width available on blended materials

クリッピングプリミティブフェード

  • デフォルトでは、クリッピングプリミティブはピクセルのクリップをオンまたはオフにします。
  • 透明な素材は、クリップの "フォールオフ "を持つことができます。
  • デフォルトは1単位のフォールオフで、「ブレンドされた素材で利用可能なブレンドクリッピングの幅」で調整できます。

f:id:yotiky:20200522081350p:plain

Per-Pixel Depth-Based Reprojection

- Allows for improved hologram stabilization, but requires depth values for every pixel
- Transparent materials don't write depth by default
- May have to also adjust rendering queues to fix sorting

ピクセル単位の深度ベースの再投影

  • ホログラムの手ぶれ補正を向上させることができますが、ピクセルごとに深度値が必要です。
  • 透明な素材はデフォルトでは深さを書かない
  • ソートを修正するためにレンダリングキューを調整する必要があるかもしれません。

f:id:yotiky:20200522081356p:plain

Per-Pixel Depth-Based Reprojection (Continued)

ピクセルあたりの深度ベースの再投影 (続き)


f:id:yotiky:20200522081402p:plain

Unity URP (LWRP) Support

- Upgrade path  available for the URP
- Only modifies how light data is sampled
- SRP Batcher support coming soon

Unity URP (LWRP) サポート

  • URPで利用可能なアップグレードパス
  • ライトデータのサンプリング方法を変更するだけ
  • SRP バッチャーのサポートは近日中に予定されています

f:id:yotiky:20200522081408p:plain

Vertex Extrusion (Continued)

- Options to verify on custom outline materials

バーテックス押出し(続き

  • カスタムアウトライン素材の検証オプション

f:id:yotiky:20200522081414p:plain

Near fade

- Used to fade in/out a hologram based on distance from the camera (or light)
- Makes opaque objets black, blended objects transparent
- Reverse values to fade when far

ニアフェード

  • カメラ(または光)からの距離に基づいてホログラムをフェードイン/アウトするために使用します。
  • 不透明なオブジェクトを黒く、ブレンドされたオブジェクトを透明にします。
  • 遠くに行くとフェードするために値を逆にする

f:id:yotiky:20200522081419p:plain

Reflection Probes

- Simply add a reflection probe to your scene
- Mark objects as "Reflection Probe Static"
- The MRTK Standard shader will automatically use reflection pro be "baked" to avoid real time computations

反射プローブ

  • シーンに反射プローブを追加するだけ
  • オブジェクトを "Reflection Probe Static "としてマークする
  • MRTK標準シェーダは、リアルタイム計算を避けるために自動的に反射プロを "ベイク "します。

f:id:yotiky:20200522081425p:plain

Reflection Probes (Continued)

- Want a reflection probe of your real-world environment?
- Try the Mixed Reality Lighting Tools by Nick Klingensmith

反射プローブ (続き)

  • 現実世界の環境の反射プローブが必要ですか?
  • Nick Klingensmithによる複合現実感ライティングツールを試してみてください。

f:id:yotiky:20200522081430p:plain

Stencil Operations

- The stencil buffer can be used to impose per-pixel restrictions on what gets rendered based on previous rasterizations
- Often used in conjunction with the render queue override
- Note, cannot be used with 16-bit depth buffers

Can be read as "when the stencil value EQUALs ONE then KEEP the pixel"

ステンシル操作

  • ステンシルバッファを使用して、以前のラスタライズに基づいてレンダリングされるものにピクセルごとの制限を課すことができます。
  • レンダーキューのオーバーライドと一緒に使用されることが多いです。
  • 注意:16ビット深度バッファでは使用できません。

ステンシルの値が1に等しい場合は、そのピクセルを保持する」と読むことができます。