Unity skill adjusts quality (textures) of the game

Source: Internet
Author: User


It 's written in front .
When we are in unity, using a picture for 2D display, we will find that the display of the screen has obvious ambiguity or sawtooth, but the artwork to the original image is very clear.

To improve the situation is actually very simple.

The reason for this is that unity automatically compresses the image (or texture) when it is imported in order to reduce the memory footprint of the Run-time game and provide performance.


Note: The unity version used by the following example is 4.3.4. Different versions may not show exactly the same thing, but the key points are the same.



Implement
We take the following background picture as an example (size is 2048*640):

When we display it as a background, we see the following effect in the game interface:

It can be found that the above image quality is not satisfactory, such as the upper left-hand corner of the sailboat and the upper right corner of the ball, there is a clear blur and sawtooth.
Observe the Inspector panel of the picture (note that the texture type here is Sprite), as follows:

The part that has an effect on the quality of the picture has been circled with a red box. According to the official website document explanation, its meaning is as follows: Filter Mode how it is filtered when the texture is stretched due to a 3D transformation. There are three kinds of choices:
Point single dot interpolation, texture will become blocky (blocky up close);
Bilinear bilinear interpolation, the texture will become blurred (blurry up close);
Trilinear is a three-linear interpolation, similar to bilinear, but the texture is also blurred between different mip levels (between different mip levels);

Maximum size of the texture imported by max size. Because art people tend to use larger textures to create, you can use this option to choose the right size for our game.

Format the internal representation used by the texture. This is the trade-off between size and quality. There are three different formats:
Compressed compressed RGB texture. This is the diffuse map of the Yangtze River format. Each pixel occupies 4bits (a 256*256 size of the texture will occupy 32KB size of memory);
Bit low quality true Color (truecolor) display. 16bits per pixel;
Truecolor true Color. This is the highest quality. A map of the size of a 256*256 occupies 256KB (8 times times that of compressed, that is, each pixel occupies 32bits).
We can view the size, format, and memory usage of the current texture from the bottom of the Inspector panel. As shown below, the current texture size is 1024*320 and will consume 160KB of memory.

If we change the filter mode to point, we can see that the screen becomes sharper. Careful observation of the edges of each object in the image, from the original blur into a block. But the quality is still bad, you can see that there are obvious sawtooth.

We reset filter mode back to bilinear. As mentioned earlier, the size of the original image is 2048*640, and the default supported max size is 1024, which means unity automatically compresses the picture. We changed max size to 2048, and when we clicked apply, we saw a noticeable improvement in the quality of the picture, and the jagged and blurry changes:

At this time the memory footprint also increased to 0.6MB, a lot bigger than before:

Finally, we try to adjust the format to TrueColor. The results are as follows:

As can be seen, the quality of the picture changes little. But memory footprint has improved a lot (3.8MB):


At this point, we can assume that the setting for this texture is filter mode to Bilinear,max size to 2048,format for compressed.


Concluding remarks
The above results are suitable for examples in the picture. In practical applications, different pictures to get the best effect settings may not be the same. Here are a few tips: when Max size is larger than the actual size of the picture, the size of the original picture is still used, so you can set it to 4096 directly if you want to use the image size. If there is a large number of large pictures in the game is the TrueColor format, it will greatly affect the memory occupancy rate. Therefore, when choosing compressed and truecolor effect is basically the same, try to choose compressed. We can set different max size and format for different platforms. For example, on the Android platform, because performance is not as good as iOS, can choose a lower quality, and on the iOS platform can be set to the highest picture.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.