Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

LZ4 Compression for assets not in asset bundles?

Discussion in '5.3 Beta' started by Wiliz, Oct 1, 2015.

  1. Wiliz

    Wiliz

    Joined:
    Feb 18, 2014
    Posts:
    20
    Will we be able to utilize the new LZ4 compression for assets that are included in the game itself and not in asset bundles? If not, why not?

    One platform where this would be especially useful is iOS. Even though apps are compressed when downloaded from the App Store, iOS has to decompress the app before it can be used. This means that uncompressed assets will take a lot of disk space, which is often very limited on low-end devices.

    For example, a single 2048x2048 texture encoded with PVRTC4 takes about 2MB uncompressed, which is how much disk space it would currently use if the game is deployed on an iOS device. If this texture was further compressed with some other compression algorithm (such as LZ4), it would obviously take much less space. (Maybe as little as 50kB - 300kB in most cases.)

    An even worse example are 32-bit truecolor textures. A single 2048x2048 texture takes about 16MB of disk space, which makes them almost unusable on iOS in current state. Compressed, the same texture would in most cases take only a fraction of the space.
     
  2. alexeyzakharov

    alexeyzakharov

    Joined:
    Jul 2, 2014
    Posts:
    507
    Hi!

    That will happen, but we can't guarantee if this will be available in 5.3 for all platforms, as this feature requires more time for testing and per-platform tuning (e.g. android with obb files).

    Right now you can use LZ4 compressed asset bundles and deploy them with your game using StreamingAssets approach.
    This might be better solution at least because of:
    • incremental data builds,
    • ability to explicitly unload unused assets and reduce assets GC time.
    And it requires minimal changes into a resource loading pipeline (if you use Resources.Load*), see e.g. https://unity3d.com/learn/tutorials/topics/scripting/assetbundles-and-assetbundle-manager

    Player's data compression will be supported for WebGL in a later 5.3 beta builds, other platforms will be included later.
    Also take in mind that player's data compression might affect final installer package size.
     
  3. Wiliz

    Wiliz

    Joined:
    Feb 18, 2014
    Posts:
    20
    Thank you for the response!

    I also realized while writing my post that you could probably achieve pretty much the same thing by putting assets into asset bundles that you include in the game. It is a workable approach, but still adds some unnecessary complexity in cases where you don't need the asset bundles for other reasons.
     
  4. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    295
    Is this still an accurate prediction, i.e. the compression won't necessarily be available for non-bundled assets in 5.3? I'm not currently using asset bundles, but am doing an Android/iOS game that is most likely going to be released with 5.3, and compressed assets would definitely come in handy. Especially since Apple and others still release 16GB devices even though it's 2015!

    I could probably switch to using asset bundles, but it'd be just simpler to let Unity compress and decompress them for me automagically. :)
     
  5. OrenMunkyFun

    OrenMunkyFun

    Joined:
    Jun 7, 2013
    Posts:
    7
    Will we be able to open LZ4 compressed bundles using AssetBundle.CreateFromFile?
     
  6. cory_munky

    cory_munky

    Joined:
    Dec 10, 2014
    Posts:
    66
    If the ProceduralMaterial texture cache was LZ4 compressed along with the bundles, I would be very, very happy :D You would be surprised how much a DXTC/PVRTC/ETC texture will still compress losslessly.
     
  7. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Hi. I added recently LZ4 support in my compression/decompression multiplatform plugin.

    http://forum.unity3d.com/threads/7zip-lzma-lz4-fastlz-zip-native-multiplatform-plugins.211273/
     
  8. alexeyzakharov

    alexeyzakharov

    Joined:
    Jul 2, 2014
    Posts:
    507
    Hi!

    Yeah, only WebGL will use Resources folder LZ4HC compression in 5.3 (by default). Support for other platforms is planned, but not for 5.3.
    You can still use AssetBundles approach to achive the same results.
     
  9. alexeyzakharov

    alexeyzakharov

    Joined:
    Jul 2, 2014
    Posts:
    507
  10. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    295
    Alright. You might want to rephrase the roadmap text though: "Introduces realtime LZ4 decompression for cached AssetBundles and Player's Data folder." To me, it implies that all assets will be compressed, asset bundle or not. That would be a nice thing to have later on, if not in 5.3.
     
  11. alexeyzakharov

    alexeyzakharov

    Joined:
    Jul 2, 2014
    Posts:
    507
    Thanks! We changed the text on Roadmap page.
    In 5.3 it will be possible to use LZ4 compression only with AssetBundles (including the bundles shipped within a game in StreamingAssets folder)
     
  12. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    124
    I've been holding back on releasing the iOS version of my 2d game because I've been waiting for something to get released that addresses the huge install size on iOS due to uncompressed textures (in my case, 16bit rgba.)

    I don't believe I can use AssetBundles since I'm using 2dToolkit. I was counting on Unity 5.3 being able to compress the player data folder, but that seems to not be happening now...at least for iOS.

    Anything on the horizon coming that could help me get the install size down? Maybe iOS crunch textures (if that's a possible thing) ? A projection date on iOS player data getting compressed?