Author Topic: NGUI for iOS, Texture Atlas compression  (Read 26956 times)

TheCrazedMadman

  • Guest
NGUI for iOS, Texture Atlas compression
« on: August 27, 2012, 06:46:41 PM »
Hey guys, I've been using NGUI for the past few months for the game I've been working on, everything has been great....love it, looks great on PC. But now that we are putting the game on iOS I have a few questions that have popped up. We have quite a few GUI textures for all the buttons spread out over several atlases (most of them 1024x1024 and sitting at 0.5 MB), and when we build it on the iOS the textures use Unitys default texture compression and make everything pixelated and frankly, look like crap. The texture type in Unity is set at GUI and Filter mode is set to Bilinear, if that helps. So we checked the "Override for iPhone" option and started messing around with the compression settings..."Compressed" (at Normal and Best), "16 Bit", and "Truecolor", all had some pixelization except for Truecolor. Which I'd be fine with if it didnt make my texture size 8x bigger (the 1024 textures are at 4.0 mb now). Is there something Im missing, or is there a better way in setting these textures compression settings to not make them pixelated, but also not enormous size wise?

Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI for iOS, Texture Atlas compression
« Reply #1 on: August 27, 2012, 07:10:51 PM »
iPhone only does PVRTC compression, which is horrible for UI textures. Simply put, for UI textures you will want to leave this on "truecolor". They're bigger, but that's why you need to be creative and reduce that as much as you can. The entire UI in Windward fits into a single 512x512 texture. Even the updated fancy UI that hasn't been released fits in a single 1024x1024. The trick is to use sliced sprites as much as you can, and reducing (and better yet - eliminating) long and narrow sprites which cause your atlas to bloat.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: NGUI for iOS, Texture Atlas compression
« Reply #2 on: August 28, 2012, 02:39:21 AM »
Well than can be hard for some games.

We have an interface with something like 5-6 screen menus, and we have 5 atlas (2048x2048) for that...
Just take the backgrounds for the interface, they need to be big (1024x768 minimum) and you've already taken almost half on one atlas.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI for iOS, Texture Atlas compression
« Reply #3 on: August 28, 2012, 02:40:38 AM »
Don't put backgrounds into the atlas. Use UITexture to draw their textures instead.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: NGUI for iOS, Texture Atlas compression
« Reply #4 on: August 28, 2012, 02:41:53 AM »
Why ? It would add a drawcall right ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI for iOS, Texture Atlas compression
« Reply #5 on: August 28, 2012, 03:02:31 AM »
Yeah but it would save you a serious amount of video memory. One draw call for the background won't make much of a difference.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: NGUI for iOS, Texture Atlas compression
« Reply #6 on: August 28, 2012, 03:03:34 AM »
Okay th en let's do this ! Thanks :)

TheCrazedMadman

  • Guest
Re: NGUI for iOS, Texture Atlas compression
« Reply #7 on: August 28, 2012, 12:26:27 PM »
We do have a few "full background" pieces that we are using NGUI for, that'll help save a few MB.....thanks, though it sucks you have to use truecolor (at least its comforting that I wasnt doing anything wrong, lol).

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI for iOS, Texture Atlas compression
« Reply #8 on: August 28, 2012, 03:33:49 PM »
Only the atlas should use truecolor. Background doesn't have to (which is another reason I suggest moving it out of your atlas).

Spacez

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: NGUI for iOS, Texture Atlas compression
« Reply #9 on: July 11, 2013, 04:49:12 AM »
sorry for bump the thread after long time no reply


after reading many thread about large textures that can not be put into the atlas.
it makes my curious that, "so what is the benefits of atlas ?" , (why dont we just use every single texture without putting them into an atlas ?)

from what i know now is about the draw call issue. But is there any more ? (in fact, i just want to know which and when i should use atlas, when UITexture when .. etc)


Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI for iOS, Texture Atlas compression
« Reply #10 on: July 11, 2013, 07:27:35 PM »
Benefit? Reduce draw calls. 100 separate textures == 100 draw calls. 100 textures in an atlas = 1 draw call. It also makes ordering easy (by depth), which makes 3D UIs possible. You can't do 3D UIs properly using separate textures. Only 2D UIs.

If you have large textures, then you're doing it wrong. You need to look at your textures and consider how to split them up into components. Have a gradient? Use a sliced sprite. Have repeated ornaments around your window? Bring them out into a separate sprite and add them on top of your window instead of having them be baked in a texture. You have to be smart about it. That's the only way you can save texture memory -- which is the most important thing when developing anything, as that's the #1 source of memory usage in any app.

rur

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 5
    • View Profile
Re: NGUI for iOS, Texture Atlas compression
« Reply #11 on: September 17, 2013, 07:36:13 PM »
You got that right about the #1 reason for large apps. I'm more smart on this now :) Wish there were more links on how to properly make GUI textures.

But I have a question on putting textures in the Atlas. In Unity you can specify the size to reduce it (if we have a 1024x1024 and in unity we can set the size to 256x256),  but if it is put into the texture atlas then all that goes away and we have to save it out as a 256x256. Is this the proper way to do this or how can I make use of the unity re-sizing so I don't have to resave all the textures.
Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI for iOS, Texture Atlas compression
« Reply #12 on: September 18, 2013, 02:00:38 PM »
You'd have to resize the textures manually before adding them to an atlas. Atlas accepts final textures in the size that they're meant to be in.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: NGUI for iOS, Texture Atlas compression
« Reply #13 on: September 18, 2013, 09:55:19 PM »
The "raw" textures you want to put in the atlas should be saved in photoshop (or your favorite cheap-skate option) in the correct resolution. Unity should not do that for you as it doesn't really rescale it as well.

dadrester

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: NGUI for iOS, Texture Atlas compression
« Reply #14 on: August 11, 2015, 05:13:57 AM »
You'd have to resize the textures manually before adding them to an atlas. Atlas accepts final textures in the size that they're meant to be in.

Just wondering if there's a Q&D workaround for this at all?

We have a large atlas for one particularly art heavy menu. The game is being developed for console and handheld and at full rez the handheld has a tendency to run out of VRAM on this particular menu (the main UI atlas is in memory permanently, but this one is loaded and binned as needed).

Because we're work in progress I'm loathed to keep 2 completely separate sets of textures and atlases in the project (given they are likely to get tweaks). I assume the reason scaling the atlas in unity breaks the UI is because coordinates are set by pixel. Just wondering what the implications would be of offering an option to convert the coords to a UV scale 0 to 1? If you know what I mean