The Mip Map Streaming system gives you control over which mipmap levels Unity loads into memory. This system reduces the total amount of memory Unity needs for Textures, because it only loads the mipmaps Unity needs to render the current CameraA component which creates an image of a particular viewpoint in your scene. The output is either drawn to the screen or captured as a texture. More info
See in Glossary position in a SceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary, instead of loading all of them by default. It trades a small amount of CPU resources to save a potentially large amount of GPU memory.
You can also use the Memory Budget to set a total memory limit for all Textures to use in a Project. The Mip Map Streaming system automatically reduces mip map levels to stay within this budget.
You can use the Mip Map Streaming API to request specific mip map levels for specific Textures. Unity provides sample C# code that duplicates the engine logic for mip map selection, which you can use to override the engine logic for your own Projects. For more details, see Mip Map Streaming API.
In Unity’s Viking Village demo project, Mip Map Streaming saves 25–30% of Texture memory, depending on Camera location.
To enable Mip Map Streaming, go to Unity’s Quality Settings (Edit > Project SettingsA broad collection of settings which allow you to configure how Physics, Audio, Networking, Graphics, Input and many other areas of your project behave. More info
See in Glossary > Quality) and enable the Texture Streaming checkbox. This reveals the settings specific to the Mip Map Streaming system. For details on each setting, see documentation on Quality Settings.
When you’ve done this, set up Mip Map Streaming on individual Textures, to allow the Mip Map Streaming system to stream each Texture’s mip maps from the disk into memory. To do this, select the Texture you want to apply Mip Map Streaming to, navigate to the InspectorA Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. More info
See in Glossary window and view the Texture Import settings. Open the Advanced settings, and enable the Streaming Mip Maps checkbox.
If you’re developing for Android, you also need to open the Build Settings and set the Compression Method to LZ4 or LZ4HC. Unity requires one of these compressionA method of storing data that reduces the amount of storage space it requires. See Texture Compression, Animation Compression, Audio Compression, Build Compression.
See in Glossary methods for asynchronous Texture loading, which the Mip Map Streaming system relies upon.
Unity loads mip maps at the highest resolution level possible while observing the Texture Memory Budget. For more specific control, or to fine-tune the Mip Map Streaming system’s automatic results, use the C# API to specify mip map levels for each Texture. For more details, see Mip Map Streaming API.
You can instruct Mipmap Streaming to calculate the required mipmap levels using one of the following methods:
If you don’t instruct Mipmap Streaming to calculate mipmap levels using one of these methods, Unity can’t calculate which mip level to use. This causes Unity to load the texture using low-quality mips that appear blurry.
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:
When a renderer is active, the mesh that renderer uses requires valid UV distribution metrics to calculate the desired mipmap level. Unity calculates distribution metrics automatically as part of the mesh importing process. You can also calculate this in a script using 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 has a built-in Mipmap Streaming debugging view mode. To access it, click the Scene view control drop-down and select Texture Streaming. This view mode tints GameObjectsThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary the following colours, depending on their status in the Mipmap Streaming system:
You can also write your own custom debug tools and visualizations using the Debugging API
Important : When the main texture is set using the MainTexture attribute, it is not visible in the game view when you use the texture streaming [[wiki:TextureStreaming-API#Debugging|debugging view mode] or a custom debug tool.
When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
More information
These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising. Some 3rd party video providers do not allow video views without targeting cookies. If you are experiencing difficulty viewing a video, you will need to set your cookie preferences for targeting to yes if you wish to view videos from these providers. Unity does not control this.
These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.