Search Unity

Texture Compression

Discussion in 'Android' started by Moradom, Apr 28, 2012.

  1. Moradom

    Moradom

    Joined:
    Oct 10, 2011
    Posts:
    33
    Hello folks,

    I have a question about texture compression for the Android platform. Since there is no standard hardware for the Android phone I am not sure what the best approach is for compressing textures. Basically, other than a few static textures a lot of our game uses 2D sprites, all of which has transparency.

    So the recommended compression ETC1 is not going to work. At this point I think I have three options

    1. Use ETC1 (since all Android phones support this) with the alpha values in another texture. This would require a custom shader that takes the RGB texture and another texture with the alpha values. I have read that people have done this, but I have not been able to find the shader code.

    2. Create a different APK for each supported texture compression (PVRTC, DXT1, ATC...etc) and use the Android market filter to "hopefully" distribute the correct APK file based on the phone's hardware. I am not sure if this approach would still cover all the Android phones. Could this approach cause our sprites to look different between phone, since we are using different compression methods?

    3. Stay with the RGBA 16 bit format. This approach really starts eating away memory. I have some texture atlases that are 1024 X 1024 and pushing 2M. A couple of these atlases then trouble...

    It seems I would get the most savings from approach one (of course there is a price with texture quality). I do not know anything about developing shaders, could someone provide the code for that shader that can be used on a mobile device?. Is this approach expensive for a mobile platform?

    I would really appreciate hearing feedback from the community on this.

    Cheers!
     
  2. Tseng

    Tseng

    Joined:
    Nov 29, 2010
    Posts:
    1,217
    First off, 2D games shouldn't use compression at all, as the compression mess up with the alpha, which will cause semi transparent areas to look horrible.

    Basically you want either to make your 2D sprites RGBA 32 Bit or 16 Bit if it's sufficient, despite the fact it's the least performant one. But on other Side you don't have complex geometry/shaders to begin off, which would already saved some performance you'd had in a 3D one.
     
    Bilelmnasser likes this.
  3. Moradom

    Moradom

    Joined:
    Oct 10, 2011
    Posts:
    33
    Thanks for the reply Tseng,

    Off hand, and I know this is a general question since each device is different. But is there some guideline on how much space one has for textures in memory on a mobile device? I have been searching for this info and I get anywhere from 10M to 128M. I am assuming that the memory for the texture is different than the program memory space.

    This is my first 2D game, but since are prototyping is mostly done we need to worry about the memory details (and a bunch of other fun stuff ;o)

    Thanks
     
  4. Tseng

    Tseng

    Joined:
    Nov 29, 2010
    Posts:
    1,217
    Mhh no, actually mobile devices usually have only one type ram which is shared between GPU and rest of the system, so the devices RAM is usually a factor.

    Android will try to free as much as possible (by closing inactive apps or stopping services as a last resort of getting RAM), until... well there's nothing more to free and the either close the app or crash.
     
    JoshBook likes this.