Search Unity

Hello everybody!

My name is Rich Geldreich, and I’m a game developer, graphics programmer, and data compression specialist. I’ve been in the trenches working on the creation, optimization, or enhancement of several major game engines at companies like Ensemble Studios (Microsoft) and Valve over the last 20 years.

Also over the years, usually late at night in between shipping games, I’ve worked on several closed and open source compression libraries originally intended for game developers, such as crunch, LZHAM, miniz, and jpeg-compressor. I also wrote picojpeg, a JPEG image decoder optimized for extremely low memory 8-bit embedded CPU’s. Outside of game products, these libraries have been utilized in a surprising variety of interesting applications, such as on picosatellites, for WebGL content delivery, for GPU accelerated UHD video decoding, and as educational material.

So what’s compression, and why is it important?

According to world expert Matt Mahoney, data compression is “the art of reducing the number of bits needed to store or transmit data”. At a different level, compression is an essential, strategically enabling technology that can save time, reduce storage space, reduce memory utilization, or reduce bandwidth. Compression can make possible things that were previously impractical or uneconomic due to available hardware, storage, or transmission resources.

There are two major classes of compression systems, such as specialized lossy systems (think JPEG or MP3), and generic lossless systems (think .ZIP). Within these two categories are an almost endless variety of applications, approaches and specialized algorithms. Some of the most essential and valuable compression systems become worldwide standards and are implemented directly into the hardware using specialized integrated circuits.

The Data Compression Team’s domain is basically anything related to compression. Internally, Unity already utilizes a number of custom and off the shelf compression systems for game assets like sounds, textures, animations, meshes, and asset bundles. Needless to say, without these systems Unity as a product would require an impractical amount of memory on many platforms, especially on mobile devices.

One of our team’s background responsibilities is to tune, optimize, and maintain our existing set of compression systems. In the near term, we’re focusing on writing a new offline and real-time generic binary data delta compressor for use by several teams within Unity. Our team’s most significant long term goal is to examine Unity’s entire software stack and determine how to break down artificial software barriers that are preventing us from getting the best possible compression solutions.

Progress So Far

Since coming to Unity, Alexander Suvorov and I have dived in and started deeply studying the lossless compression field’s current state. Lossless compression technology allows Unity’s downloadable asset bundle files to require significantly less space and time to download. Our goal was to identify not only where the state of the art is, but to predict where the field is going. We’ve also talked about our long term view of the field of GPU texture compression.

On the practical front, we’ve developed and started analyzing our first mobile-friendly binary delta compression (or file “patching”) library. This standalone library can be used whenever Unity needs to efficiently transmit a set of “new” data given a (hopefully related) set of “old” data present at both endpoints. Finally, we’ve started testing a Javascript version of the LZHAM lossless data compressor for web applications.

During our lossless survey, we found at least one major feature we can add to current lossless compressors that would enable us to readily build new types of custom texture, geometry, and animation compressors. We’re also considering completely redefining how data is fed into a lossless compressor. After some great discussions with Unity developers on the Cloud Build and Services teams, we’ve begun researching and planning what it would take to modify our current offline mobile delta compressor to work in real-time.

Finally, while doing this work, we realized the key long-term problem the Compression Team should be working on: How do we build a data compression engine that Unity can talk to better? Our long term goal is to build several new lossy and lossless compression engines optimized specifically for Unity’s data.

These are very exciting times at Unity, and I can’t wait to see what the future holds.

Ya no se aceptan más comentarios.

  1. Rich, if you are working with compression please take a look at this idea, and my comment in particular:
    https://feedback.unity3d.com/suggestions/editor-display-asset-bundles-in

    It involves asset bundles and would probably require a rewrite for it to work. But its an interesting feature to have and could have a lot of applications for dev-to-dev and dev-to-prosumer/orWhatnot exchanges.

    Regardless, good luck with your work, we all appreciate what you do.

  2. Great plans!
    But what about compression in current Unity branches? Is it possible to send/receive network traffic, for example via WWW class, using standard gzip/deflate algorithms? Natively, without 3rd-party libraries or plugins.

  3. I hope you guys focus on Android (which has APK limitations) and iOS first. I believe these 2 platforms are to focus first so that we can have something soon. (I hope)

  4. Welcome Rich! It sounds like you are deep into image compression. Did you have a look at the HAP codec? AVPro Windows Media from the Asset Store supports this and I am using it frequently. Why not make the HAP codec run natively in Unity?
    https://github.com/vidvox/hap
    https://www.assetstore.unity3d.com/en/#!/content/2546

  5. Thank you for the useful information! Our company experts greatly appreciate it! Have you already estimated the time that you need to create a data compression engine that will be perfect for Unity? When can we expect the first release?

  6. Just wanted to add my support for better iOS data compression of some sort. My old Cocos2d game has a 50MB installed size. I converted and upgraded that game to Unity, but it now has a 500MB installed size due mostly to uncompressed textures. I’m not going to release this update because that’s too much of a size increase to impose on my users. Maybe the solution that Matt suggested above here is what people in my situation need? If the data compression you talk about in the article is the solution, then that’s great, but how long will that take to get out the door?

  7. Do you guys feel that Google’s brotli could prove beneficial for Unity-based game deployments?

    1. Google’s Brotli codec looks very promising. Over the holidays I’ll be conducting a series of tests comparing Brotli with some other commercial and open source codecs, on a wide variety of test data.

  8. Wow!!
    so many things that i have been hoping to see for years in unity are being announced one after the other :D !!
    you guys are making great work ! keep it up and best of luck :)

  9. Nice.

    One feature relate to data and compression that can be great to have is the ability to know an asset’s size for the built platform. For example – how much does a texture take ? A prefab? A scene?

    The build log prints a list of assets sorted by their size, but this is the uncompressed size so it’s pretty meaningless…

    BTW not sure this feature is even possible to develop :)

    1. We are actually working on a build reporting feature, that extracts exactly such data for you.

      1. Awesome !! bring it on !!

    2. On that note another great feature would be to add the compressed byte size to the asset bundle manifest so that loading bars developers can easily estimate the size to download a set of many bundles making progress bars friendlier and more accurate.

  10. That’s great and all, but maybe you could spend a few days implementing this feedback item first. Currently, it’s nearly impossible to have an acceptable build size AND nice looking graphics (ie, no banding or compression artifacts) for mobile games. People have resorted to work-arounds like loading PNG files from Resources at runtime but then you lose out on all the other nice Unity features for those assets. Even if this compression team plans to handle this situation in the future, I bet it’ll be many months, maybe years before a solution is integrated and we need a solution sooner than that.

    1. Hi Matt – Thanks for pointing this out. I recently helped ship a large mobile game using Unity, so I understand how important this is. Let me investigate the situation.

      1. Thanks for looking into it!

  11. Cool. While you’re at it, can you please make available some kind of fast/capable data compression for use in scripting… such as lzma or better… ie to compress and/or decompress a byte array at runtime. Then I/we can dabble with implementing our own compression schemes on our own data, not just on Unity’s data.

    1. Got any examples of the usage cases, so we can better understand your needs?

      1. Voxel objects with a few byte of data per block.
        (Currently using Mike Krueger’s GZipInputStream c# library.)

      2. Just custom data mainly, arrays of data that maybe I precalculated to save runtime performance, that I want to then expand at runtime. It could be texture data or maybe a level. For example to load a losslessly compressed image at runtime without it having to be stored in an expanded texture format for e.g. for 2d graphics. Or maybe there’s some data file that I created, maybe it represents colors or a precalculated animation or something. Typically it’s a byte array.

        I’d also like to see compression used in build targets like windows/mac and web to get the file sizes down to help with download speed.

        1. I think this is a great idea!

  12. Wish best of luck to you, Alexander and Rich.

    1. Thanks a lot Tuti!