Search Unity

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

Question Is there a lighter format for sprites ?

Discussion in 'UGUI & TextMesh Pro' started by Askiparait, Aug 21, 2023.

  1. Askiparait

    Askiparait

    Joined:
    Mar 10, 2018
    Posts:
    5
    Hello, i would like to know if formats we choose for sprites in Unity could improve performance and reduce lags in game.
    For example, between the format "Automatic + No compression", is there a difference with "RGBA 32 bit" ? If so, which one ?

    Thanks
     
  2. sildeflask

    sildeflask

    Joined:
    Aug 16, 2023
    Posts:
    329
    this is for memory, not for cpu
     
  3. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    582
    Unless you are running out of VRAM texture changing texture formats will unlikely give you a meaningful performance improvement or help with lagging. Your problem is more likely somewhere else. Start profiler and find out what your current performance bottleneck is and what is cause of lags. You can also check the currently used VRAM amount there.
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,328
    Sure, if that's what's causing your problem. Is it?

    DO NOT OPTIMIZE "JUST BECAUSE..." If you don't have a problem, DO NOT OPTIMIZE!

    If you DO have a problem, there is only ONE way to find out. Always start by using the profiler:

    Window -> Analysis -> Profiler

    Failure to use the profiler first means you're just guessing, making a mess of your code for no good reason.

    Not only that but performance on platform A will likely be completely different than platform B. Test on the platform(s) that you care about, and test to the extent that it is worth your effort, and no more.

    https://forum.unity.com/threads/is-...ng-square-roots-in-2021.1111063/#post-7148770

    Remember that optimized code is ALWAYS harder to work with and more brittle, making subsequent feature development difficult or impossible, or incurring massive technical debt on future development.

    Don't forget about the Frame Debugger either, available right near the Profiler in the menu system. Remember that you are gathering information at this stage. You cannot FIX until you FIND.

    Notes on optimizing UnityEngine.UI setups:

    https://forum.unity.com/threads/how...form-data-into-an-array.1134520/#post-7289413

    At a minimum you want to clearly understand what performance issues you are having:

    - running too slowly?
    - loading too slowly?
    - using too much runtime memory?
    - final bundle too large?
    - too much network traffic?
    - something else?

    If you are unable to engage the profiler, then your next solution is gross guessing changes, such as "reimport all textures as 32x32 tiny textures" or "replace some complex 3D objects with cubes/capsules" to try and figure out what is bogging you down.

    Each experiment you do may give you intel about what is causing the performance issue that you identified. More importantly let you eliminate candidates for optimization. For instance if you swap out your biggest textures with 32x32 stamps and you STILL have a problem, you may be able to eliminate textures as an issue and move onto something else.

    This sort of speculative optimization assumes you're properly using source control so it takes one click to revert to the way your project was before if there is no improvement, while carefully making notes about what you have tried and more importantly what results it has had.
     
  5. Askiparait

    Askiparait

    Joined:
    Mar 10, 2018
    Posts:
    5
    Thanks for you answers.

    My problem is simple : at some points, i have many, hundreds, of Image GameObjects on screen at the same time, and it becomes laggy. Especially when they are superposed.

    I know i have multiple solutions (having less GameObjects and so on), but i was wondering if the "format" option of the sprites could change anything, and how ?
    What changes it makes and which ones exaclty ?

    Here are some screen, before it becomes laggy :




    And when it becomes laggy :

     
  6. sildeflask

    sildeflask

    Joined:
    Aug 16, 2023
    Posts:
    329
    this wont be solved by anything in the import settings
     
  7. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,161
    That's UI (UGUI), not 2D features (as it says in the profiler) so this is the wrong forum (completely different team). The UI can use sprites but they are really just textures and 2D features are not rendering it.

    There's a forum for UGUI which I can move your post to.
     
  8. Askiparait

    Askiparait

    Joined:
    Mar 10, 2018
    Posts:
    5
    Yes thanks
     
    MelvMay likes this.