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