Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feature Request Why is there no option to compress terrain splat maps on build?

Discussion in 'World Building' started by joeysipos, Mar 27, 2023.

  1. joeysipos


    Jul 28, 2015
    Is there no option to compress splat maps for a build? I understand Unity uses uncompressed splat maps on the terrain in order to paint textures correctly. But the splat maps take up way to much memory and disk space. If the terrain splatmap atlases where compressed in DX5 format it would take up 1/4 the memory and disk space plus increase performance. According to this thread:

    Why can't there be an option to compress the splatmap atlases at build?
    Last edited: Mar 27, 2023
  2. AshwinMods


    Jul 1, 2014
    I totally agree, there should be an option, specially for mobile builds.
    I manually compressed the terrain splatMaps to ASTC 8x8, and I was happy with the tradeoff of size and quality.

    Until unity provides such option, Here is what you can do,

    Firstly, please MAKE BACKUPS of terrain data. You may lose decent progress in these tricks,

    1. You can call Texture2D.Compress in Editor on AlphaMaps of TerrainData,
    You don't have much control what compression will be applied, but you get a smaller build.

    2. You can export the AlphaMaps as png, apply preferred compression
    Reinitialize AlphaMaps of terrain with same Texture Format, which will clear all the pixels
    but now you can use Graphics.CopyTexture to copy that data from you exported texture to AlphaMaps
    Code (CSharp):
    2.     [MenuItem("CONTEXT/Texture2D/Export as PNG")]
    3.     public static void Export_PNG()
    4.     {
    5.         Texture2D l_Tex = Selection.activeObject as Texture2D;
    6.         var l_Bytes = l_Tex.EncodeToPNG();
    7.         var l_Path = EditorUtility.SaveFilePanel("Save File", Application.dataPath,, "png");
    8.         if (!string.IsNullOrEmpty(l_Path))
    9.         {
    10.             File.WriteAllBytes(l_Path, l_Bytes);
    11.         }
    12.     }
    3. You can try this plugin, (I have not)
    This promise to compress other data as well like Normal, BaseMap, Heightmap.

    In our project though, We moved from terrain to mesh upto LOD 2, as we needed a lot more flexibility,
    and we were able to get reduced build size, memory and triangle count.