画面にジオメトリを描画するために、Unity はグラフィックス API に対してドローコール (draw call、描画呼び出し) を送信します。ドローコールはグラフィックス API に対して、何をどのように描画するかを指示します。各ドローコールには、テクスチャ、シェーダー、バッファに関する情報など、グラフィックス API が画面に描画するために必要なすべての情報が含まれています。ドローコールはリソースを消費しますが、多くの場合、ドローコール自体よりも、ドローコールの準備の方に多くリソースが消費されます。
ドローコールに備えるため、CPU はリソースを準備し、GPU の内部設定を変更します。これらの設定はまとめてレンダー状態と呼ばれます。レンダー状態の変更 (例えば、別のマテリアルに切り替えるなど) は、グラフィックス API が実行する中で最もリソースを消費する操作です。
レンダー状態の変更はリソースを消費するためそれらを最適化することが重要です。レンダー状態の変更を最適化する主な方法は、レンダー状態の変更の回数を減らすことです。これには 2 つの方法があります。
ドローコールとレンダー状態の変更を最適化することは、アプリケーションにとって多くの利点があります。主にフレーム時間が改善されますが、それ以外にも以下のような利点があります。
Unity では、ドローコールとレンダー状態の変更を最適化して減らすために、いくつかのメソッドを使用できます。いくつかのメソッドは、他のメソッドよりも特定のシーンに適しています。Unity では以下のメソッドが利用可能です。
position
(位置) と normal
(法線) のような同じ数と種類の属性をもつ場合です。同じシーンで複数のドローコール最適化メソッドを使用することができますが、Unity のドローコール最適化メソッドには、特定の優先順位があることに注意してください。ゲームオブジェクトに複数のドローコール最適化メソッドを使用するように設定すると、Unity は最も優先度の高いメソッドを使用します。唯一の例外は、SRP バッチャー です。SRP バッチャーを使用する場合、Unity は SRP バッチャーと互換性があるゲームオブジェクト に対し静的バッチ処理もサポートしています。Unity は、ドローコールの最適化に次の順序で優先順位を付けます。
ゲームオブジェクトを静的バッチ処理に設定すると、Unity がバッチ処理に成功した場合、レンダラーがインスタンシングシェーダーを使用する場合も、ゲームオブジェクトの GPU インスタンシングを無効にします。この場合、Inspector ウィンドウに警告メッセージが表示され、静的バッチ処理を無効にするよう促されます。同様に、Unity がメッシュの GPU インスタンシングを使用できる場合、Unity はそのメッシュの動的バッチ処理を無効にします。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.