Mip Map Streaming (ミップマップストリーミング) システムは、Unity がメモリにロードするミップマップレベルを制御します。このシステムは Unity がテクスチャのために必要な合計メモリ量を削減します。なぜなら、ミップマップストリーミングシステムは、デフォルトでシーン内のすべてのミップマップをロードするのではなく、シーンの現在のカメラ位置のレンダリングに必要なミップマップのみをロードするからです。これにより、少量の CPU リソースと引き換えに、多くの GPU メモリを節約することが可能です。
ミップマップストリーミングの Memory Budget (メモリバジェット) を使用して、プロジェクトで使用するすべてのテクスチャの合計メモリ量を設定することもできます。ミップマップストリーミングシステムは自動的にミップマップレベルを下げてこの設定内に留めます。
ミップマップストリーミング API を使用して、特定のテクスチャに特定のミップマップレベルをリクエストできます。Unity は、ミップマップ選択のためのエンジンロジックを複製するサンプルの C# コードを提供しています。これを使用して、プロジェクトのためにエンジンロジックをオーバーライドできます。詳細は、ミップマップストリーミング API を参照してください。
Unity の Viking Village デモプロジェクトでは、ミップマップストリーミングはカメラの場所に応じて、テクスチャメモリの 25 - 30% を節約します。
ミップマップストリーミングを有効にするには、Unity の Quality 設定 (Edit > Project Settings > Quality) に移動し、Texture Streaming チェックボックスをチェックします。これにより、ミップマップストリーミングシステム特有の設定が表示されます。各設定の詳細は、Quality 設定 を参照してください。
これを行うと、個々のテクスチャにミップマップストリーミングを設定し、ミップマップストリーミングシステムが各テクスチャのミップマップをディスクからメモリにストリーミングできるようにします。これを行うには、ミップマップストリーミングを適用するテクスチャを選択し、インスペクターウィンドウに移動し、テクスチャインポートの設定を表示します。 Advanced 設定を開き、Streaming Mip Maps チェックボックスにチェックします。
Android 用に開発する場合は、Build Settings (ビルド設定) を開き、Compression Method を LZ4 か LZ4HC に設定する必要があります。 Unity では、ミップマップストリーミングシステムが依存する 非同期テクスチャのロード にそれらの圧縮方法の 1 つが必要です。
Unity はテクスチャの Memory Budget を観察しながら、可能な限り高い解像度レベルでミップマップを読み込みます。より詳細な制御や、テクスチャストリーミングシステムで自動的に得た結果の微調整を行うには、C# API を使用して各テクスチャのミップマップレベルを指定します。詳細は、ミップマップストリーミング API を参照してください。
以下のいずれかの方法で、ミップマップストリーミングに必要なミップマップレベルの計算をするよう指示できます。
これらの方法のいずれかを使用して、ミップマップレベルを計算するようにミップマップストリーミングに指示しないと、Unity はどのミップレベルを使用するかを計算できません。このことは、Unity が低品質のミップを使用してテクスチャをロードし、ぼやけて見える原因になります。
The following systems don’t use standard Renderers. This means you must manually set the requested mips for these systems or Unity loads the textures they use at low resolution:
レンダラーがアクティブなとき、レンダラーが使用するメッシュは、望ましいミップマップレベルを計算するために有効な UV 分布メトリクスを必要とします。Unity では、メッシュのインポートプロセスの一環として、自動的に分配メトリクスを計算します。また、Mesh.GetUVDistributionMetric を使って、スクリプトで計算することもできます。
If you create a mesh from code, Unity does not calculate distribution metrics automatically. This causes Unity to load the wrong mipmaps. For example, it may load low-resolution textures when the camera is close to a mesh. To manually trigger the UV distribution metric calculation use Mesh.RecalculateUVDistributionMetrics.
When Unity renders a streamed Texture directly with an API (such as Graphics.DrawMeshNow the system has no renderer bounds or other information to calculate the mip level. This means you need to set the Texture mip level manually or disable Mipmap Streaming on this Texture. See Texture2D.requestedMipmapLevel for more details on how to manually set which mip level Unity loads.
When Unity calculates the miplevel for a texture it looks for the scale and translation of that texture in a _ST
value with the same name as the texture flagged in your shader. For example, if you reference your textures are in the shader using _MainTex
, Unity will look for _MainTex_ST
.
Unity にはビルトインのミップマップストリーミングデバッグビューモードがあります。それにアクセスするには、シーンビューの描画モードのドロップダウン をクリックし、Texture Streaming を選択します。このビューモードでは、ミップマップストリーミングシステム内でのゲームオブジェクトの状態に応じて、ゲームオブジェクトに以下の色を設定します。
また、デバッグ API を使って、独自のカスタムデバッグツールやビジュアライゼーションを作成することもできます。
重要 : メインテクスチャが MainTexture 属性を使用して設定されている場合は、テクスチャストリーミング デバッグビューモード またはカスタムデバッグツールを使用すると、ゲームビューに表示されません。
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.