Author Topic: Broken Atlas on old Android devices  (Read 4001 times)

Aze

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
Broken Atlas on old Android devices
« on: September 17, 2015, 10:42:58 AM »
Hello everyone.

First, thanks ArenMook for making such a great plugin; I've been working with it for a long time and it's great. It's the first time I have an issue like this.

Here's my issue:

My game renders UI nicely across most Android devices. However, on older devices which only support ETC1 compression format (which doesn't support Alpha channel if I understand correctly), all sprites and bitmap fonts just show white rectangles (screenshot as attachment).

My Atlas material has the shader Unlit/Transparent Colored, and the Atlas texture has the import settings as Editor GUI and Legacy GUI. Either filters settings don't change anything.
The Texture Compression in the Build Settings is set to ETC (default).

I can reproduce it within the editor by selecting the atlas' texture, setting it to Texture import type and checking the Alpha from Greyscale checkbox. Maybe that means that old devices have this option forced at runtime, and they end up trying to get alpha values from the Atlas' grayscale, and that information is missing in my atlas?

Would that mean that I need to extract the alpha channel from the Atlas texture, save it in a separate file, and change the shader on the Atlas that would handle that?

If that's the case, which shader should I use to achieve this?

I'm using Unity 5.2 and NGUI 3.9.2.

Thank you very much for reading.
« Last Edit: September 27, 2015, 12:30:08 PM by Aze »

cbartlett

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 43
    • View Profile
Re: ETC1 breaks Atlas
« Reply #1 on: September 17, 2015, 12:37:12 PM »
I may be incorrect but I believe you need to change the texture(compression) you are using.  It is not a shader issue but the compression on the texture. 

Aze

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: ETC1 breaks Atlas
« Reply #2 on: September 17, 2015, 12:43:16 PM »
Thank you for your reply, cbartlett ;)

I have tried many different texture compression and I do not know which one I should use. You mean not Editor GUI and Legacy? Because my aim is to stay in ETC because I need the game to run on these devices.

I unfortunately do not have an old enough device to try and run each texture import parameter one by one. My client reported this issue to me and he is not reactive at all so I cannot send him build to try out... And this bug only happens on his device (Galaxy Trend).

I really have a feeling it's due to the alpha channel stored in the atlas... But I cannot find a way to actually do without it.

cbartlett

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 43
    • View Profile
Re: ETC1 breaks Atlas
« Reply #3 on: September 17, 2015, 12:46:53 PM »
I have had similar difficulties in the past and for those textures I chose no compression on the texture.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: ETC1 breaks Atlas
« Reply #4 on: September 20, 2015, 02:35:21 AM »
UI textures should remain Truecolor. You should not be compressing them at all. Texture compression produces compression artifacts and is only suitable for 3D models. PVRTC compression also requires images to have square dimensions, while UI textures are often rectangles instead. I am not sure if ETC compression has the same limitation, but Unity will use PVRTC on mobiles. This means that Unity will force atlas textures to be square, and all your UI texture coordinates will suddenly become off -- thus the issue you're seeing.

P.S. ETC1 compression has no alpha channel. You need alpha for UIs.

Aze

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: ETC1 breaks Atlas
« Reply #5 on: September 27, 2015, 12:28:53 PM »
Hello to you all,

Thanks ArenMook for your response.

I've managed to correct the issue with having the actual device in hands. The TrueColor or compressed texture format wasn't the issue.

Setting the texture type to anything but Texture creates this issue on old devices like Samsung Galaxy Trend, even with no texture override in the build settings, and setting everything to TrueColor.

If anyone has this issue, you need to set your Atlas file import type to Texture. I have not managed to find another texture import type which doesn't create this problem - even though I tried every single option in the Advanced mode.

Thank you all again,
Cheers,

Dezachu

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Broken Atlas on old Android devices
« Reply #6 on: September 28, 2015, 03:39:22 AM »
Aware you've fixed the problem now but I had the exact same graphical issue a couple of days ago. The issue was that the atlases were large r than 2048x2048 which Android doesn't appear to like.

Just thought I'd mention this incase it helps someone else in future.

Aze

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Broken Atlas on old Android devices
« Reply #7 on: September 28, 2015, 05:02:27 AM »
Hello Dezachu,

Thank you very much for you input! I have tried to limit atlases to 2048x2048, and had to put my fonts in a separate atlas. With that done, I can now set the Atlases textures to any import type I want: Editor GUI, Advanced, etc. and everything works peferctly on old devices, ETC1 or not!

Great!

So, to correct this issue... Simply limit your atlases to 2048x2048 on Android, and it'll run everywhere even with ETC1 without any issues :)

Thanks again, all!

Cheers,
Aze.