Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
CloseFor some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
CloseThe number of high resolution mipmap levels from the texture that Unity doesn't upload to the GPU. (Read Only)
Unity takes a texture's mipmap limit settings into account to determine its active mipmap limit that affects how many texture mipmap levels are uploaded to the GPU. This property provides the active number of texture mipmap levels that Unity didn't upload to the GPU. This number is relative to the number of texture mipmap levels included in the build.
Unity ensures that a certain platform-dependent number of mipmap levels are always uploaded regardless of the texture's mipmap limit. activeMipmapLimit
can therefore be smaller than expected in certain cases.
When PlayerSettings.mipStripping is enabled, which strips mipmap levels from textures, activeMipmapLimit
returns a limit that accounts for the number of mipmap levels stripped. For example, a texture with 3 stripped mipmap levels and an applicable QualitySettings.globalTextureMipmapLimit value of 3 has a activeMipmapLimit
value of 0. This value is because the number of mipmap levels that Unity uploads to the GPU is the same as the number of mipmap levels included in the build.activeMipmapLimit
also reflects any downscale fallbacks applied by EditorUserBuildSettings.androidETC2Fallback or AndroidETC2FallbackOverride.
The following code example demonstrates how you can use activeMipmapLimit
to perform a Graphics.CopyTexture operation on the GPU to copy the highest resolution mipmap level of a texture that uses mipmap limits to a new texture that does not use mipmap limits.
using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Experimental.Rendering;
public class Example : MonoBehaviour { [SerializeField] Texture2D m_SourceTexture;
public void ExecuteCopyTexture() { if ((SystemInfo.copyTextureSupport & CopyTextureSupport.Basic) == 0) { Debug.LogError("Cannot perform CopyTexture, there is no support on this platform."); return; }
if (!SystemInfo.IsFormatSupported(m_SourceTexture.graphicsFormat, GraphicsFormatUsage.Sample)) { Debug.LogError("Cannot perform CopyTexture, the source texture's GraphicsFormat is not supported on this platform."); return; }
// The width and height of the texture in the build need to be halved for each mipmap level that wasn't uploaded to the GPU int width = m_SourceTexture.width >> m_SourceTexture.activeMipmapLimit; int height = m_SourceTexture.height >> m_SourceTexture.activeMipmapLimit;
// No mipmap limit applies because the texture doesn't have mipmaps. Texture2D destinationTexture = new Texture2D(width, height, m_SourceTexture.format, false);
// GPU copy of the mipmap level 0 to the mipmap level 0 of the destination texture. // The mipmap level 0 on the GPU is smaller than the mipmap level 0 of the texture in the build when m_SourceTexture.activeMipmapLimit is greater than 0. Graphics.CopyTexture(m_SourceTexture, 0, 0, 0, 0, m_SourceTexture.width, m_SourceTexture.height, destinationTexture, 0, 0, 0, 0); } }
Additional resources: QualitySettings.globalTextureMipmapLimit, mipmapLimitGroup, ignoreMipmapLimit.
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.