Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Good practices to optimize texture size

Discussion in 'General Discussion' started by rogerdv, Sep 12, 2023.

  1. rogerdv

    rogerdv

    Joined:
    Jul 16, 2012
    Posts:
    87
    Im working with a team that didnt have a programmer before, so all of their work was made by an artist. They are in need to optimize build size and after studying what they did, I found a couple of things. First, some textures are NPOT and Unity itself reports they cant be compressed.I guess that the first step is to change all textures to POT resolutions, isnt it? Also, they have tried reducing jpg/png file quality to reduce image size. Correct me if Im wrong, but I think that such method is irrelevenat, because Unity should convert images to its own format for exporting (like most engines do). So, what we should do is to use the optimal resolution: instead of having a 1000 pixel texture for a 1200 pixel screen (mobiles are the only target) and then scale it to a quarter of screen size, better have a 500 pixel or less image from the beginning.
    What else can we do to optimize texture size?
     
  2. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    530
    Yes input file compression jpg/png is irrelevant.

    The stuff you can do:
    * ensuring texture compression can be enabled (might require POT size as you said). How high compression you can set and whether you can change NPOT to POT will depend on art style. For example you probably don't want texture compression and can't freely resize pixelart.
    * Appropriate texture size -> you can limit texture size not only by directly resizing input image but also using the max texture size in import settings and project settings for each target. This is more relevant for games that are released on PC and mobile, since you might want to keep original size on PC and limit it for mobile.
    * Sprite atlases -> sprite atlases won't reduce memory usage directly but it can help in two ways. If you have concave shaped sprites with large cutouts sprite atlas can allow you to easily nest them and thus save space. For better nesting set the tight outline mode in sprite import settings and the tight packing option in sprrite atlas properties. Sprite atlas will also have POT size, thus you can satisfy the POT requirement for compression by combinging multiple sprites in single sprite atlas without changing size of each individual sprite. Sprite atlases can only be used if you are using images as sprites, it won't work if you are using the as textures for 3d meshes.

    Those are the major things that can be done without major restructuring of the games.

    If you have a bunch of large fullscreen animations currently stored as images you might also want to take a look at my answer in this post https://forum.unity.com/threads/importing-large-2d-animations-performance.1344353/
     
    rogerdv likes this.