Unity3d of the Research institute modify the size of the baking map & the script baking scene

Source: Internet
Author: User

The size of each baking map after the unity default bake scene is 1024. But it is possible that your scene is relatively simple, with 1024 will be more wasteful. As shown, this is a baking map for one of my scenes, and a large portion of the upper right corner is completely unused, but it occupies space.

Sometimes you want to modify the size of the baking map, as shown before I tried to modify the size of the baking map in the Inspector View, although the figure is small, but it is the overall narrowing, and then found on the mobile phone this way directly modify the size of the baking map is indeed a problem, the seam aspects of dealing with problems. And every time you bake a scene, you need to shrink it. (Never do this)

We need art to set the size of the baking map while baking the scene, but Unity's baking menu does not have the size of the baking map set at all. Then I thought of a clever way to bake a scene with a foot, and set the size of the baking map by the way. The code is simple.

Clear () deletes the baking map for the current scene.

Bake () is directly baking the current scene, and I can add some code before baking the scene ... Everything is scripted. Hey..

Maxatlasheight and Maxatlaswidth is the width and height of each baking map, generally we use a 512 of each scene is almost. The baking map must have a power of 2 and be square.

12345678 [MenuItem("Test/test")] static void Init() { lightmapeditorsettings. Maxatlasheight = + ; lightmapeditorsettings. Maxatlaswidth = + ; lightmapping. Clear(); lightmapping. Bake(); }

This art is used only in the Lightmapping window to set the parameters of the current baking scene. Call us to write the extended menu method on it. The size of the baking map I set here is 512.

Using the above method, we narrowed down a 1024 map to 512, and the effect didn't change much, but the space deficit shrank 4 times times.

IOS PVRTC Compression After 512 of the map is only 170.8KB, it is very force bar.

    • This article fixed link: http://www.xuanyusong.com/archives/2815

Unity3d of the Research institute modify the size of the baking map & the script baking scene

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.