Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity is not a serious 2D game dev platform without support for lossless texture compression

Discussion in '2D' started by mattparkins, Mar 10, 2015.

  1. mattparkins

    mattparkins

    Joined:
    Apr 1, 2014
    Posts:
    31
    I can't take Unity seriously as a 2D game production platform because I can't use half of the tools. Why?

    The reason is that Unity does not support lossless texture compression. I'm making 2D iOS games, iOS supports the PNG format, and even if it didn't support it I'd be happy to wait the few seconds it takes to decompress the PNGS a sprites. My choices then are:

    1. Use uncompressed textures. I cannot do this as my game would then be over 300 MB. My source images are PNG files, and are 1/20th of the size of the uncompressed images and any game over 50MB is an obvious target for uninstallation.

    2. Use compressed textures. I cannot do this as the format offered (PVRTC) is lossy compression - the quality of the textures is too low, frankly it's awful. I'm making 2D games, the expectation is high-quality, not low-quality.

    3. Write my own script to load PNGs saved as file.png.bytes into a Texture2D and then into a Sprite and be unable to use many unity tools, plugins and workflow. This is what I have to do right now.

    My question is at what point will Unity address this obvious flaw?

    Until support for lossless texture compression (at least on iOS) is in Unity then it cannot be considered a serious 2D platform.
     
    Last edited: Mar 10, 2015
  2. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Are you needing to have ALL of those objects active in graphics memory at one time? If so, unless there is HARDWARE texture compression in use in realtime, you have no option but to use RGBA 32-bit textures for all of it if you want perfect quality. This isn't a unity thing, it's how the hardware/graphics card works. what you're really asking for is being able to store the graphics in a compressed format which is only decompressed when the object is displayed, like in a shader, or by the graphics hardware. There is no such thing.

    But is your issue mainly to do with FILE size, or runtime memory usage? For file size, I agree you have to load the compressed files and decompress on the fly in a custom solution.

    Another option for you, is to use palletized images, 256-color images are 1/4 the storage space, and you can render them using a paletted shader to convert back to 24-bit. Although alpha channel is extra.
     
    Simon-F and theANMATOR2b like this.
  3. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    I'm guessing you mean compressed textures on desk, not in memory. In which case I think you might want to look into getting 2D Toolkit. It supports PNG compression plus much, much more.
     
  4. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    I think Unity is trying to make itself a better 2d platform.. many good 2d games were already released using the non-2d tools before verison 4.3 or whatever.... and now there are some 2d tools..... but there is still room for improvement.... things like tilemaps and palettes and simplified fake physics and stuff like that... may or may not make it into the engine, I guess we'll see.
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It is a serious 2D platform because there have been many good 2D games made with it that have sold zillions of copies. That's the only real criterion. Sure, some kind of built-in on-disk compression would be nice, but it's not actually necessary and engaging in hyperbole doesn't really help your point.

    --Eric
     
    Thiemo, hippocoder and theANMATOR2b like this.
  6. mattparkins

    mattparkins

    Joined:
    Apr 1, 2014
    Posts:
    31
    I'm really surprised at the lack of understanding being shown here. The issue is the storage space on device, not runtime RAM.

    I'm writing a game that has 300MB+ of uncompressed 2D sprites. If stored as PNGs the size would be 15MB - that's 5% of the uncompressed size - but as it is it has to be stored on device at 300MB and is a perfect candidate for uninstallation, or use custom scripts to load and decompress the textures.

    Thanks ShaderOp for the nudge toward 2DToolkit - that looks like what I'm looking for, though I'd simply like the PNG save/load feature without all the other bumf.
     
    fokziu likes this.
  7. mattparkins

    mattparkins

    Joined:
    Apr 1, 2014
    Posts:
    31
    Eric, it is absolutely necessary to have support for the storage of losslessly compressed textures.

    Ignoring the importance of this point does not help your post.
     
  8. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    I get what the op is asking... it would actually be nice to be able to use the normal workflow, and perhaps mark a texture as losslessly compressed, so that on-disk it's stored in a compressed format .. maybe using LZMA or something, and decompressed at runtime .....i Know the webplayer uses LZMA compression... but I guess not iOs?
     
  9. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Obviously it's not necessary, or published 2D Unity games wouldn't exist. Again with the hyperbole; I can't take that seriously. You can either leave the textures uncompressed, which doesn't prevent your game from working or being downloaded (300MB isn't actually that big of a deal these days, and Apple just upped the max size from 2 to 4GB), or you can store them as PNG and load them manually, which may reduce the efficiency of your workflow somewhat, but doesn't prevent you from making the game at all. Being able to use PNG and convert that to uncompressed automatically at runtime is classified as "would be nice to have and ideally should be implemented", not "absolutely necessary".

    --Eric
     
  10. mattparkins

    mattparkins

    Joined:
    Apr 1, 2014
    Posts:
    31
    Yes, it really would be useful to use the normal workflow. I'd be happy with any kind of lossless texture compression. The funny thing is that iOS actually supports PNGs anyway - it's all right there.
     
  11. mattparkins

    mattparkins

    Joined:
    Apr 1, 2014
    Posts:
    31
    What planet are you on? My issue is NOT with the size of download or bandwidth required, but the amount of space the app takes up installed on the device. How hard is this to understand?

    A 300 MB install as opposed to 45MB one is a major issue. Most mobile devices are not flush with storage space, users often look to delete large games and anything 50 or 100MB is absolutely asking to be uninstalled - ergo lossless texture compression IS absolutely necessary.
     
  12. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    How hard is it for you to understand that I never said otherwise? Apparently pretty hard.

    That's not at all true in the real world.

    Also false, since the previous statement was false. You don't seem to understand the definition of "necessary". You can either live with uncompressed textures as they are, which is workable but not ideal, or you can save textures as PNG and manage them that way, which is also workable but not ideal. If in your head using PNG on the device is "absolutely necessary", fine, go ahead and do that. Unity doesn't prevent it. I already agreed that being able to use PNG automatically would be nice, but hysterically overstating your case isn't helping you.

    --Eric
     
  13. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    How bout lower the resolution of some/all textures? That's an option -
    All devs have to balance optimizations with quality level.
     
  14. PockeTiger

    PockeTiger

    Joined:
    Nov 30, 2013
    Posts:
    7
    This is one interesting thread to read.

    I'm not quite sure on it's point with all those aggressive tones though. Respect for the community as they are trying to help but...

    The OP seems to be agitated over a problem that may be solved (with some compromises of course.. but who didn't made any while making games?)
    The Mod didn't really helped much on the situation either by feeding the troll either.

    It seems this way at least on my opinion and sorry for sharing but I think this is a really good example on how people can just jump at eachother over nothing.

    This problem could be very well addressed by a suggestion for an additional feature and I assume then this whole thread would hit a very different tone of conversation. I'm just sad people tend to still go the other way around this and expect that things happen their way, someone else solve their problems and not after weeks... months... or so development but in the very moment they are ordered to. Cause everyone love when they are yelled at.

    This whole story is just a bit... sad.
    [-1 faith in humanity]
     
    CanisLupus likes this.
  15. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    I'm not sure all that many people actually go and look and delete stuff based on filesize.... apple has done a good job of completely hiding the idea of `files` and bytes of storage and all that. You can just hold down your finger on an app icon and `[x] it out` to delete it, deleting based on stuff you don't like any more rather than being so short on storage that you have to prune. I think most people would get rid of stuff based on which apps they like or don't like. Make your app likeable and people will keep if it's 300 megs and worth it. Sure some people will look at sizes and do a prune, but how many?
     
  16. mattparkins

    mattparkins

    Joined:
    Apr 1, 2014
    Posts:
    31
    Hey, yeah, I know quite a few people who, when they are reaching capacity of their iOS device go to the Settings | Usage and look at the list of installed apps and make the decision about what to delete based on the app size - the list is sorted by App size. For me, in the circles I travel in and the people I talk with I'd say it is 80% of those that have 16GB devices / entry level devices do this. Otherwise, like you say, I wouldn't be bothered.

    I'm using 2DToolkit to fill this and some other missing features that Unity has with respect to 2D and that has been a lifesaver.
     
  17. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    I can see people doing that because I use the same approach even on my laptop. I sort by file size and uninstall / delete from the top down. It is just the most efficient way to free up space. For mobile games (which I am just getting into) if the game is huge I don't even bother installing it no matter how good it looks. However for me the app permissions are the most important criteria for installation all other things being equal. I look for apps that require "no special permissions" first and foremost and second only in app purchases.
     
    mattparkins likes this.
  18. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Howdy Team Rage!

    Whilst this isn't a solution it seemed pertinent to mention here so here goes. We're aiming to get Crunch texture compression into Unity 5.1 (as always no promises but it's in alpha right now), this offers really good compression which although lossy is barely noticeable and offers huge savings, a quote from one of our alpha testers -

    "Even at 100% quality, some of my 1024x1024 textures that are 0.7MB compressed crunch down to 124k ! And that look almost identical."

    Sadly for this use case it won't help as this is only for DXT platforms so won't solve what you're describing, just wanted to let you know we're working on various avenues to alleviate issues like this. We also just formed a new larger team around 2D recently, I'm meeting with them today to discuss user needs so will bring this up.

    til then enjoy watching some of these totally not serious Unity 2D trailers





    Love & hugs,

    Will
     
  19. mattparkins

    mattparkins

    Joined:
    Apr 1, 2014
    Posts:
    31
    Thanks Will,

    I'm happy that it is being looked into - I presume there must be a technical reason why PNG isn't supported in Unity iOS given that iOS does support it natively, but I do hope you're able to get to it soon.

    For this game I've switched to using 2DToolkit.

    Ta,

    Matt
     
  20. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    124
    Just wanted to say that the option to store your images on disk as PNG is really important. I'm converting my 2D puzzle game from Cocos2D to Unity and ran into this issue. The Cocos2D version is under 50MB installed on device. Currently the Unity version is over 550MB installed. That's really significant considering how many mobile devices out there are only 16GB and older ones even less. I'm going to have to look into 2DToolkit's trickery to help with this.
     
  21. hasen

    hasen

    Joined:
    Apr 1, 2015
    Posts:
    29
    I'm not really sure about the replies to his post, they're very odd. Of course 300MB is an issue. In any case even if you could make it 250MB instead of 300 its worth having - how can you argue that its not needed? I would certainly go through and delete apps that are 100MB+ if I felt I was starting to run out of space. They would certainly be the first apps to go. Maybe amazing games wouldn't be deleted but they would if you'd played it to death recently but maybe if you didn't delete it then you might play it again in a few months. Also other games aren't amazing but are addictive and you may want to play them at any given time - but not if they're 300MB...
     
  22. CluelessMuffin

    CluelessMuffin

    Joined:
    Feb 14, 2015
    Posts:
    63
    I agree with the OP, I made a very simply 2D balloon popping game and it's taking 50MB on storage (13MB apk size).
     
    HungryGames and mattparkins like this.
  23. CluelessMuffin

    CluelessMuffin

    Joined:
    Feb 14, 2015
    Posts:
    63

    Ori and Broforce are windows/Xbox/PS4 games, so storage size wouldn't matter much.

    A 300-500MB and even 1GB game on a PC or console is nothing, on a phone it's huge.
     
    mattparkins likes this.
  24. CluelessMuffin

    CluelessMuffin

    Joined:
    Feb 14, 2015
    Posts:
    63
    Angry birds just takes 80MB and it's more complicated and animated by far.

    And 2D Toolkit is pretty expensive while it should be a built-in feature for unity, not acceptable.

    OP, how far your game was reduced after 2D Toolkit?
     
    HungryGames likes this.
  25. TomasJ

    TomasJ

    Joined:
    Sep 26, 2010
    Posts:
    256
    Unity will soon be compressing all game data, solving size problems on mobiles. Watch the release notes.
     
  26. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    While you are at it, can you make an LZMA compression and decompression commands available from scripts for runtime compression/decompression of byte arrays?
     
    mattparkins and HugoZandel like this.
  27. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That would be a very useful addition.

    --Eric
     
  28. Wisteso

    Wisteso

    Joined:
    Nov 17, 2013
    Posts:
    50
    @willgoldstone

    I did a bit of digging around on Crunch and saw that PVRTC support was on the horizon, but the project also dropped off the face of the planet a few years ago.

    PVRTC is really the only bad apple in the basket (of compression techniques). DXT5 is pretty good already... ASTC has Android covered pretty well...

    So if you guys could get Crunch working with PVRTC devices, I think Unity would become so much more amazing for developing larger iOS games.
     
  29. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    How much compression would be acceptable (without any quality loss)? Are you trying to get to like 1 byte per pixel or 2 bytes per pixel? It seems that to go from 300mb to 50mb you are ideally looking for 4 bits per pixel. Now, if you want that to be lossless compression, your image is going to have to contain a lot of reduncancy and repetition in order for any compressor to have a chance to reach that kind of compression ratio without losing any data.

    Crunch is not lossless, either.

    Also PVRTC is one of the best-quality compressions I've seen .... can you post some images of how your image looks when it is compressed, and how that is unacceptable?
     
    Last edited: Sep 10, 2015
  30. AndyKorth

    AndyKorth

    Joined:
    Oct 19, 2009
    Posts:
    41
    Crunching textures that aren't DXT compressed would also be great. A 4k by 4k texture at 32 bits per pixel is 67 megabytes (4096*4096*32). And as RGBA, it's going to be that size in memory.. but many of my 4k spritesheets are drastically smaller on disk when trivially compressed. Unfortunately, in the desktop builds, these assets aren't compressed at all and could be drastically smaller. Yes, I understand and agree that people should expect steam games to be many hundreds of mb, but it's convenient for many reasons to take some simple steps to reduce these sizes.

    This issue can be replicated by including a 4096x4096 RGBA 32 bit solid white PNG in a blank project. Do a Mac or Windows build and note the huge size of the resulting app. (sharedassets0.assets, etc).

    Also note that you can compress the game folder really well, since it's 60+ mb of zeros. (although you can't play the game when it's compressed)
     
  31. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    You could put that 64mb texture into the resources folder as a png bytestream and load it and decompress it at runtime, it's just that it requires a small script.

    I do agree though that an LZMA or fast ZIP compression/decompression (maybe as an option?) has been long overdue for desktop targets. For that matter, as I maybe mentioned here or elsewhere, it'd be really useful to expose LZMA compression/decompression functions for script use at runtime, so we can do our own compression. But I suppose the png bytestream method which uses GZIP is almost that. Would be nice if it was automatic.
     
    Last edited: Sep 16, 2015
  32. HungryGames

    HungryGames

    Joined:
    Nov 23, 2014
    Posts:
    3
    Glad for the OP he solved this problem before he started the development.
    In my case – the game is already production ready and what you suggest is to 100% redo the whole game, and break all the workflow just to solve the obvious issue: 30 kb PNG image shouldn't be equal to 1 mb in production? The same - 2D puzzle game with 15 mb of png partially transparent assets is 350 mb on the device. And I have really no choice now, It took several months to develop, the only option is to deploy to the markets with that huge size (or do you think I should redo all the work made? Or to use the compression that ruins the quality? It's really-really-really ugly). And I understand why the OP is so pissed off, I'm pissed off even more.
    It's my first project, so I really didn't expect that incredible absurdity from the major game dev platform.
    In terms of business that means that the project will have less download conversion and higher bounce rate because of the size. And that's definitely a hit on a wallet.
     
    Last edited: Dec 10, 2015
    knockknock and djfrail like this.
  33. originalterrox

    originalterrox

    Joined:
    Feb 6, 2015
    Posts:
    40
    I assumed images would be compressed as PNG or similar unless specifically set otherwise for a particular texture. To realise that resources are uncompressed on disk is disappointing as it is one of the things I dislike about a lot of "large" supposedly AAA games when I find that they have uncompressed graphics (or audio). Don't tell me the music is uncompressed too! :/ I am targetting old devices, so I would have to put more time into optimisation than I'd really want to.
     
  34. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Images are whatever you set them to. If uncompressed, then they're uncompressed. If DXT or other compression, then they are DXT or whatever. The source format isn't relevant, aside from the fact that if you use a lossy-compressed format (JPG) and compress again, more quality is lost, so source files should always be lossless if possible.

    It's the same as textures. If an audio file is set to uncompressed, then it's uncompressed. If not (Vorbis etc.), then not. Again, the source format isn't relevant; same caveat as above.

    --Eric
     
  35. originalterrox

    originalterrox

    Joined:
    Feb 6, 2015
    Posts:
    40
    So what is the point of this topic? Set it to PNG and the installed app should be small on Android.
     
  36. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The point of this topic is that there's no option for that, aside from actually including PNG images as assets and loading them manually at runtime.

    --Eric
     
  37. Nodrap

    Nodrap

    Joined:
    Nov 4, 2011
    Posts:
    83
    I'm presuming we've not made any progress on this issue? :(

    So long ago this really useful idea was postulated and nothing?

    I'm working on a WebGL build and this issue becomes VERY important for me as I want a quick startup and asset bundle loads. I will probably be changing to a text-texture reference system and put the PNG's in the streaming assets folder to solve this.

    A real shame considering this could be quite nicely handled by an engine.
     
  38. Scott-Steffes

    Scott-Steffes

    Joined:
    Dec 31, 2013
    Posts:
    59
    For this situation I find enabling LZ4HC compression in the overall build settings helps a good deal. LZ4HC can make your 32bit uncompressed images quite a bit smaller, especially if your images have a limited color palette.
    In my game we have a ton of uncompressed pixel art,
    with LZ4HC turned off the build is about 1.5GB,
    with LZ4HC turned on the build is about 250MB.
    When the images are decompressed they still take up a ton of space in RAM/VRAM but a solution involving PNGs would have the same problem.
    The only way to keep the images small all the way through is to use a format that your graphics card can read.

    The only unfortunate thing is that you can't tell how much space each image actually takes up. In the inspector it will still say the image is huge (12mb+ for some of our sprite sheets) which is how much space it will take up in RAM, but it would be nice to also see how much space it will take up once LZ4HC compressed.
     
    Lars-Steenhoff likes this.
  39. fodel

    fodel

    Joined:
    May 5, 2021
    Posts:
    4
    Unity compressera bientôt toutes les données du jeu, résolvant les problèmes de taille sur les mobiles. Regardez les notes de version.












    snaptube vidmate
     
    Last edited: Jun 14, 2021