Texture compression unity android что выбрать
Unity Texture Compression (Android and iOS)
Unity iOS & Android Texture Compression Guide Overview
Unity texture compression is a very important step to developing mobile games for android or iOS. Keeping the filesize of your game build low means players are able to download the game faster and some may even abandon the download if it’s taking too long!
This guide explains how to do unity android texture compression as well as unity iOS texture compression and also explains other texture optimization techniques to improve unity mobile rendering performance!
Why Should I Compress Unity Textures?
Textures are generally the main cause of high build filesizes, especially when you have a lot of textures at higher resolutions! Texture compression in Unity allows you to reduce the filesizes of your textures and in most cases makes no visual difference!
You can find out exactly what’s causing your build filesizes to be so high with the Editor Log. After making a build open the editor log from the dropdown menu top right of the console (Open the console from Window > Console) (Alternatively on windows it can be found in %localappdata%/Unity/Editor/)
In the editor log search for ‘Used Assets and files from the Resources folder, sorted by uncompressed size:‘. Below this line is a list of all assets included into the build ordered by their filesize.
From here you can go through the assets and determine what you can do to compress or remove some of these items. This guide explains how you can compress the images (Textures) from this list.
Viewing the Target Texture Import Settings
Unity texture import settings can be adjusted by selecting the texture in the project window to show the texture import settings in the inspector window.
From the texture import settings you can set texture compression, control mip-mapping and adjust few other useful texture settings.
(If you don’t have the project window or inspector window visible you can add them from Window > Project and Window > Inspector and if selecting objects from the project window isn’t showing the import settings try pressing the lock icon top right of the inspector)
With your texture selected you’ll want to select your target platform and tick the override checkbox (In older versions of Unity you could just set the compression format from the default tab to affect all platforms, however this was changed in later versions of Unity 5. – Note if you’re using an older version of Unity you need to set the Texture Type to Advanced before you are given the option to select specific compression formats rather than just automatic)
Unity Texture Compression Options
Max Size
This will set the maximum resolution allowed for this texture, e.g if your texture is 3000×3000 setting this to 2048 will set the texture resolution to 2048×2048, if the original texture size is smaller than the selection e.g 2000×2000 then setting this to 2048 will not affect the texture resolution, keeping it at native file resolution.
Compression
This is found in the default tab and seems to be the replacement for auto compression from the older versions of Unity. I recommend keeping track of your textures and manually setting the unity texture compression where possible.
Auto compression may be good enough if you’re feeling lazy, however I personally have never seen a difference between low, medium and high quality levels visually or filesize-wise so I’m not entirely sure what difference they make.
Format
The texture compression format which the texture will be compressed with. You should try stick to a specific format across your entire project to ensure you don’t run into compatibility issues.
On Android when a compression format isn’t natively supported it’ll switch to software decompression which is MUCH slower. Usually for Android you’ll want to stick with ‘ETC2’ texture compression formats, using ‘RGB Compressed ETC2 4 bits’ for opaque textures and ‘RGB + 1-bit Alpha Compressed ETC2 4 bits’ for transparent textures.
However if the textures appear glitchy or transparency stops working then use ‘RGBA Compressed ETC2 8 bits’ which results in a slightly higher texture filesize but should fix any issues with the texture.
Compressor Quality
Visible after selecting some compression formats. This sets the level of compression between fast, normal and best – I have never personally seen any texture changes in filesize or visual quality from setting this on any compression methods other than crunched (which will degrade the texture quality)
Note that setting best on some textures (usually textures with transparency) causes Unity to hang for a long time, so you probably should just leave this set to ‘Normal’ unless you are using a crunched compression format or have some other reason to change it.
Mip Maps
What Are Mip Maps?
Mip maps are smaller versions of the original texture which are used instead of the actual texture when the rendered object is far away from the rendering camera.
They improve GPU rendering performance as the GPU renders much smaller textures and can also reduce texture aliasing without anti-aliasing being needed.
How To Use MipMaps
Under the Advanced section of the texture import settings is a checkbox to ‘Generate Mip Maps’ this will generate the smaller versions of your texture to be generated and built into your game alongside the full sized texture (You can preview mip-maps with the mip-map slider).
Rendering the smaller mip-map textures which are used at a distance is much faster for GPU rendering and reduces harsh aliasing at a distance, especially when used with anisotropic filtering.
This example uses strong colour contrasts to make the aliasing effects more obvious but you can see how mipmaps and different filtering levels affect rendering.
Note that generating mipmaps increases the total filesize of the texture by about 25% so if you’re trying to keep filesize low and either the texture looks fine at a distance, will never be viewed at a distance or GPU rendering costs aren’t an issue then you can keep mipmaps disabled to reduce game filesize.
(Make sure Anisotropic Textures are enabled in your Quality Settings if you want to filter your textures!)
POT Textures
What Are POT Textures and NPOT Textures?
POT & NPOT stand for ‘Power of Two’ and ‘Non Power of Two’.
A POT texture is where a texture has a resolution of 2^n x 2^n (which means the height and width is either 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096.. etc).
NPOT is the reverse of this, a texture which does not have a height/width which is a power of 2.
Only POT textures can be compressed if mipmaps are enabled
If you’re trying to compress a NPOT texture with mipmaps enabled Unity might warn you that ‘Only POT textures can be compressed if mipmaps are enabled’.
You can either directly edit your texture or use Unity’s built in texture import settings to force squash or stretch the texture to be power of two.
Expanding Advanced there’s an option for ‘Non Power of 2’ this will allow you to make Unity slightly squash or stretch a texture to the nearest power of 2.
The reasons why POT textures are important is because unless the texture is POT you won’t be able to use some compression formats and mipmaps cannot be used on the texture.
(On old hardware you may find that NPOT textures use more memory than expected too as they’re being stored into memory as next highest POT sizes!)
Additional Tips
Remember that not all textures will be equally visible in games, some textures may never even be visible up close! In cases where textures won’t come close to the camera you could probably bring your texture resolution down to a lower level and enabling mipmapping to improve render costs.
If you’re developing a mobile game you try also try not to go over the top with level of detail! On small mobile screens detail won’t be as visible as it is in your editor screen so consider bringing resolutions lower and previewing them on a phone or tablet.
I also always suggest using texture compression on ALL your textures! There should be a compression method which works for you in all cases without any or very little visual change.
Recommended, default, and supported texture compression formats, by platform
This page contains the following information:
This page does not contain information about console platforms. For information about console platforms, see the platform-specific documentation.
For an overview of texture compression formats, see Texture compression formats. For information about texture import settings and how to set up platform-specific overrides, see Texture import settings.
Terminology
This page uses the following terminology:
Recommended texture compression formats, by platform
Desktop
See the Supported texture compression formats reference table for detailed information about all supported formats.
iOS and tvOS
See the Supported texture compression formats reference table for detailed information about all supported formats.
Android
Texture compression support on Android is complicated, and you might need to build several application versions with different sub-targets.
Unless your app targets specific hardware that supports a limited range of texture compression formats, you can choose between several compressed and uncompressed formats, which offer different trade-offs.
For devices that don’t support ASTC HDR, all devices running Vulkan, Metal, or OpenGL ES 3.0 support RGB9e5, which is suitable for textures without an alpha channel. If an alpha channel or even wider support is needed, use RGBA Half. This takes twice as much memory as RGB9e5.
See the Supported texture compression formats reference table for detailed information about all supported formats.
Default texture compression formats, by platform
The following table shows the default formats used for each platform.
Platform | Color model | None | Normal quality (default) | High quality | Low quality (higher performance) |
---|---|---|---|---|---|
Windows, Linux, macOS | RGB | RGB 24 bit | RGB Compressed DXT1 | RGB(A) Compressed BC7 | RGB Compressed DXT1 |
RGBA | RGBA 32 bit | RGBA Compressed DXT5 | RGB(A) Compressed BC7 | RGBA Compressed DXT5 | |
HDR | RGBA Half | RGB Compressed BC6H | RGB Compressed BC6H | RGB Compressed BC6H | |
WebGL A JavaScript API that renders 2D and 3D graphics in a web browser. The Unity WebGL build option allows Unity to publish content as JavaScript programs which use HTML5 technologies and the WebGL rendering API to run Unity content in a web browser. More info See in Glossary | RGB | RGB 24 bit | RGB Compressed DXT1 | RGB Compressed DXT1 | RGB Compressed DXT1 |
RGBA | RGBA 32 bit | RGBA Compressed DXT5 | RGBA Compressed DXT5 | RGBA Compressed DXT5 | |
Android (only when Don’t override is enabled in the build settings) | RGB | RGB 24 bit | RGB Compressed ETC | RGB Compressed ETC | RGB Compressed ETC |
RGBA | RGBA 32 bit | RGBA Compressed ETC2 | RGBA Compressed ETC2 | RGBA Compressed ETC2 | |
iOS | RGB | RGB 24 bit | RGB Compressed PVRTC 4 bits | RGB Compressed PVRTC 4 bits | RGB Compressed PVRTC 2 bits |
RGBA | RGBA 32 bit | RGBA Compressed PVRTC 4 bits | RGBA Compressed PVRTC 4 bits | RGBA Compressed PVRTC 2 bits | |
tvOS | RGB | RGB 24 bit | RGB Compressed ASTC 6×6 block | RGB Compressed ASTC 4×4 block | RGB Compressed ASTC 8×8 block |
RGBA | RGBA 32 bit | RGBA Compressed ASTC 6×6 block | RGBA Compressed ASTC 4×4 block | RGBA Compressed ASTC 8×8 block | |
Default | RGBA | RGBA 32 bit | RGBA 16 bit | RGBA 16 bit | RGBA 16 bit |
Supported texture compression formats, by platform
The table below shows each compression format available in Unity, and the platforms that support it.
Texture compression format | Description | Channels | Quality | Bits per pixel | Size of 1024×1024 texture, in MB | Windows | Mac | Linux | Android | iOS & tvOS | WebGL |
---|---|---|---|---|---|---|---|---|---|---|---|
RGB(A) Compressed BC7 | Compressed RGB or RGBA | RGB or RGBA | High | 8 | 1 | yes (1) | yes (1) | yes | no | no | no |
RGBA Compressed DXT5 | Compressed RGBA (also known as BC3) | RGBA | Medium | 8 | 1 | yes | yes | yes | no (3) | no | partial (2) |
RGBA Crunched DXT5 | Compressed RGBA, with additional on-disk Crunch compression | RGBA | Low to medium | Variable | Variable | yes | yes | yes | no (3) | no | partial (2) |
RGBA 64 bit | Uncompressed RGBA, very high precision | RGBA | Very high | 64 | 8 | yes | yes | yes | partial (6) | yes | no |
RGBA 32 bit | Uncompressed RGBA | RGBA | High | 32 | 4 | yes | yes | yes | yes | yes | yes |
RGBA 16 bit | Quantized RGBA | RGBA | Medium | 16 | 2 | yes | yes | yes | yes | yes | yes |
RGB Compressed DXT1 | Compressed RGB (also known as BC1) | RGB | Medium | 4 | 0.5 | yes | yes | yes | no (3) | no | partial (2) |
RGB Crunched DXT1 | Compressed RGB, with additional on-disk Crunch compression | RGB | Low to medium | Variable | Variable | yes | yes | yes | no (3) | no | partial (2) |
RGB 48 bit | Uncompressed RGB, very high precision. Converted to RGBA 64 bit for the GPU | RGB | Very high | 48 disk, 64 GPU | 6 disk, 8 GPU | yes | yes | yes | partial (6) | yes | no |
RGB 24 bit | Uncompressed RGB. Converted to RGBA 32 bit for the GPU | RGB | High | 24 disk, 32 GPU | 3 disk, 4 GPU | yes | yes | yes | yes | yes | yes |
RGB 16 bit | Quantized RGB | RGB | Medium | 16 | 2 | yes | yes | yes | yes | yes | yes |
RG Compressed BC5 | Compressed two channel (RG) | RG | High | 8 | 1 | yes | yes | yes | no | no | no |
RG 32 bit | Uncompressed two channel (RG), very high precision | RG | Very high | 32 | 4 | yes | yes | yes | partial (6) | yes | no |
R Compressed BC4 | Compressed single channel (R) | R | High | 4 | 0.5 | yes | yes | yes | no | no | no |
R 8 | Uncompressed single channel (R) | R | High | 8 | 1 | yes | yes | yes | partial (5) | yes | partial (5) |
R 16 bit | Uncompressed single channel (R), very high precision | R | Very high | 16 | 2 | yes | yes | yes | partial (6) | partial (6) | no |
Alpha 8 | Uncompressed single channel (A) | A | High | 8 | 1 | yes | yes | yes | yes | yes | yes |
RGBA Half | HDR, half-precision (FP16) RGBA, –64k to +64k range | RGBA | High | 64 | 8 | yes | yes | yes | partial (7) | yes | partial (7) |
RGB Compressed BC6H | HDR, compressed RGB, 0 to +64k range | RGB | High | 8 | 1 | yes (1) | yes (1) | yes | no | no | no |
RGB9e5 32 Bit Shared Exponent Float | HDR, quantized RGB, 0 to +64k range | RGB | Medium | 32 | 4 | yes | yes | yes | partial (4) | yes | partial (4) |
RGB(A) Compressed ASTC | Compressed RGB or RGBA, size & quality dependent on block size | RGB or RGBA | Low to high | 12×12: 0.89, 10×10: 1.28, 8×8: 2, 6×6: 3.56, 5×5: 5.12, 4×4: 8 | 12×12: 0.11, 10×10: 0.16, 8×8: 0.25, 6×6: 0.45, 5×5: 0.64, 4×4: 1.0 | no | no | no | partial (8) | yes (10) | no |
RGBA Compressed ETC2 | Compressed RGBA | RGBA | Medium | 8 | 1 | no | no | no | partial (9) | yes | no |
RGBA Crunched ETC2 | Compressed RGBA, with additional on-disk Crunch compression | RGBA | Low to medium | Variable | Variable | no | no | no | partial (9) | yes | no |
RGB + 1-bit Alpha Compressed ETC2 4 bits | Compressed RGBA, with alpha values fully opaque or fully transparent | RGBA | Medium | 4 | 0.5 | no | no | no | partial (9) | yes | no |
RGBA Compressed PVRTC 4 bits | Compressed RGBA, texture required to be square | RGBA | Medium | 4 | 0.5 | no | no | no | no (12) | yes | no |
RGBA Compressed PVRTC 2 bits | Compressed RGBA, texture required to be square | RGBA | Low | 2 | 0.25 | no | no | no | no (12) | yes | no |
RGB Compressed ETC2 | Compressed RGB | RGB | Medium | 4 | 0.5 | no | no | no | partial (9) | yes | no |
RGB Compressed ETC | Compressed RGB | RGB | Low | 4 | 0.5 | no | no | no | yes | yes | no |
RGB Crunched ETC | Compressed RGB, with additional on-disk Crunch compression | RGB | Low | Variable | Variable | no | no | no | yes | yes | no |
RGB Compressed PVRTC 4 bits | Compressed RGB, texture required to be square | RGB | Medium | 4 | 0.5 | no | no | no | no (12) | yes | no |
RGB Compressed PVRTC 2 bits | Compressed RGB, texture required to be square | RGB | Low | 2 | 0.25 | no | no | no | no (12) | yes | no |
RG Compressed EAC 8 bit | Compressed two channel (RG) | RG | High | 8 | 1 | no | no | no | partial (9) | yes | no |
R Compressed EAC 4 bit | Compressed single channel (R) | R | High | 4 | 0.5 | no | no | no | partial (9) | yes | no |
RGB(A) Compressed ASTC HDR | HDR, compressed RGB or RGBA, size & quality dependent on block size | RGB or RGBA | Low to High | 12×12: 0.89, 10×10: 1.28, 8×8: 2, 6×6: 3.56, 5×5: 5.12, 4×4: 8 | 12×12: 0.11, 10×10: 0.16, 8×8: 0.25, 6×6: 0.45, 5×5: 0.64, 4×4: 1.0 | no | no | no | partial (11) | partial (11) | no |
Notes: