Hello Guest

Author Topic: Atlas Compression  (Read 9762 times)

habitoti

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 82
    • View Profile
    • Rombos Homepage
Atlas Compression
« on: February 09, 2014, 04:48:15 pm »
Hi,

a Unity texture can be compressed by a variety of formats (especially ETC for Android, see below). Is there a reason that it's rather limited for the TK2D Atlas when set to "Unity Texture"? I might be completely misled, but from what I read, at least for Android it's strongly recommended to use ETC.

I can change the compression to ETC2 once I created an atlas with uncompressed unity texture setting, but on every new commit it is then switched back to truecolor. It would be great if I could choose that compression upfront already, or if there would be a configurable postprocessing step to apply the desired compression to it.

Regards, habitoti

« Last Edit: February 09, 2014, 05:44:37 pm by habitoti »
Checkout our homepage or visit the Rombos blog.

habitoti

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 82
    • View Profile
    • Rombos Homepage
Re: Atlas Compression
« Reply #1 on: February 09, 2014, 07:42:20 pm »
I think I found it myself  8)

I can simply override the compression for deployment to the device. This setting is retained even I re-commit the sprite collection...
Checkout our homepage or visit the Rombos blog.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Atlas Compression
« Reply #2 on: February 09, 2014, 09:28:20 pm »
That should do it. You do realise ETC doesn't support alpha, right? I've been warning to put in a post build callback so you can split up the atlas into 2 ETC textures for alpha support, not got around to it yet. I've put that in the roadmap for tk2d 2.5. Now to get the next 2.4 release done...

habitoti

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 82
    • View Profile
    • Rombos Homepage
Re: Atlas Compression
« Reply #3 on: February 09, 2014, 09:35:13 pm »
Yeah, but I have quite a number of rectangular sprites that don't have alpha. Wish ETC2 would be available for GLE2 already -- it's so much better...
Checkout our homepage or visit the Rombos blog.

habitoti

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 82
    • View Profile
    • Rombos Homepage
Re: Atlas Compression
« Reply #4 on: February 10, 2014, 06:02:58 pm »
After digging a bit deeper, it looks like ETC is really the only useful compression for Android deployments (since for all others you might end up with SW decompression, which makes no sense), but it works only on non-alpha atlasses (ETC2 is much better, but only available with GL3 and probably only on very few HW today)
So a great value prop for TK2D would be to support an RGB/Alpha split under the hood of an atlas, plus a shader that recombines them later on. Such atlasses could both be ETC compressed.
Not sure how much work that would be, but Android devs would love you for that!
Checkout our homepage or visit the Rombos blog.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Atlas Compression
« Reply #5 on: February 11, 2014, 09:46:46 am »
That would be trivial to implement. The issue is supporting it seamlessly across the board.
Stuff like this is so annoyingly complicated in Unity - for starters adding the rgb/alpha tex ref to this object will mean those textures get included in other builds too. Once you work around something like that its also really annoying that you've gotta constantly keep on top of it as Unity keep changing behaviours...

I think its realistic to add support for a post build callback, and even maybe have a little plug in that splits up a texture into 2 ETC RGB / A textures. Beyond that point it gets into very very messy territory.

habitoti

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 82
    • View Profile
    • Rombos Homepage
Re: Atlas Compression
« Reply #6 on: February 11, 2014, 10:31:29 am »
But wouldn't you just need to create one RGB and one Alpha texture on "commit" in the collection, and there is a special flavor of sprites that is based on such a "twin collection", including the special shader to rejoin both channels again? You just include two textures (both of which can then be ETC compressed), and beyond that it would be compeletely transparent for the developer...how would Unity prevent you from that?
Checkout our homepage or visit the Rombos blog.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Atlas Compression
« Reply #7 on: February 11, 2014, 10:46:52 am »
Doing that would be rather wasteful on all other platforms - the ideal solution is to do that only on android. Its fine if you're only doing android dev, but almost everyone using tk2d does cross platform stuff with it. The point is its not exactly easy to have an android only variant of that material with the 2 textures, automatically.

habitoti

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 82
    • View Profile
    • Rombos Homepage
Re: Atlas Compression
« Reply #8 on: February 11, 2014, 09:44:05 pm »
Well, it's not wasteful at all in general. You are just splitting off one layer (24+8 bit vs. 32), so uncompressed it's basically the same total texture space consumption. And next you can define a per-platform compression that has the widest HW implementation adoption (e.g. ETC on Android, PVRTC for iOS etc.), and furthermore non-alpha compressions are usually better (even in SW) and have a broader availability, so there would be lot of applications for such a mode, I believe. I think this would be a big advantage to offer it (nobody _has_ to use it...), not just limited to Android.

Anyway, just my 2 cents  ;)
Checkout our homepage or visit the Rombos blog.

coshea

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: Atlas Compression
« Reply #9 on: November 24, 2014, 12:35:32 pm »
+1 vote for this as a possible feature too, would be great :)

EvolveGames

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Atlas Compression
« Reply #10 on: June 10, 2015, 04:00:06 pm »
Has this been implemented? (The ETC1+Alpha spliting) I saw it on trello for 2.5 but can't find anything inside Unity.
Would love any news/workaround! Thanks in advance

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Atlas Compression
« Reply #11 on: June 12, 2015, 11:31:39 am »
No. Not planning to implement this. However, we did add a callback when a sprite collection is built.
tk2dSpriteCollectionBuilder.OnPostBuildSpriteCollection

You can hook into that, do what you want with the output textures there without modifying tk2d source. This happens right at the very end of the build, so you can assume everything is complete by then.