Author Topic: Reduce size of atlas  (Read 4357 times)

smtabatabaie

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Reduce size of atlas
« on: April 03, 2017, 09:53:53 AM »
Hi, Recently I did a build on my app on iOS and observed it was too large , after seeing the editor.log I saw that it was because my main atlas. This atlas has 40 icons in it. the size of its png texture is 1.3 mb in finder but in unity it says it is 85.3 mb! the texture is 4096 truecolor. I tried to make it 2048 and it helped a lot but the problem is all the sprites smash together and are not shown correctly. I'll appreciate if you know any tips on how to reduce the size of my atlas.
Thanks very much

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Reduce size of atlas
« Reply #1 on: April 03, 2017, 10:11:45 AM »
Sounds like the individual sprites are quite big. Step 1 would be to see if you can make them smaller and still get the result you want. If that doesn't work, consider not putting them in an atlas, but as "raw" textures and use a UITexture instead of a UISprite to put them on screen.

smtabatabaie

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: Reduce size of atlas
« Reply #2 on: April 03, 2017, 11:17:19 AM »
Sounds like the individual sprites are quite big. Step 1 would be to see if you can make them smaller and still get the result you want. If that doesn't work, consider not putting them in an atlas, but as "raw" textures and use a UITexture instead of a UISprite to put them on screen.
If I can make this atlas texture 2048 it will solve the problem but as I said if I do that sprites will smash together. I reduced the size of all textures but still I can't reduce atlas texture to 2048 . Redoing it with UiTexture will take a lot of time and will probably cause many bugs and redoing.
I'll appreciate if you can help me with this.
Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Reduce size of atlas
« Reply #3 on: April 04, 2017, 05:37:44 AM »
40 sprites fill up a 4k atlas? That implies your sprites are roughly 100x100 pixels each.

For sprites that large, I don't advise using an atlas. Keep them as textures and use UITexture to display them. Atlases are great for keeping lots of small sprites together, saving draw calls and texture space.

Also keep in mind, if you want you can load your PNG dynamically. Just have a script that loads an image and sets the atlas material's main texture in an Awake() of some script that will load first as soon as you start your app.

Or just enable compression on the atlas texture so that it's not truecolor.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Reduce size of atlas
« Reply #4 on: April 04, 2017, 03:03:18 PM »
Sounds like the individual sprites are quite big. Step 1 would be to see if you can make them smaller and still get the result you want. If that doesn't work, consider not putting them in an atlas, but as "raw" textures and use a UITexture instead of a UISprite to put them on screen.
If I can make this atlas texture 2048 it will solve the problem but as I said if I do that sprites will smash together. I reduced the size of all textures but still I can't reduce atlas texture to 2048 . Redoing it with UiTexture will take a lot of time and will probably cause many bugs and redoing.
I'll appreciate if you can help me with this.
Thanks

Don't resize the resulting atlas, resize your source image and then update the atlas with them. Then your sprites will still work, albeit they will have less image data, if you follow me. This way, you won't lose the texture coordinates that you will when you just resize the atlas texture itself.