Search Unity

Crunch fails in Unity 2017.3 for MTX files

Discussion in 'General Discussion' started by markgrossnickle, Feb 19, 2018.

  1. markgrossnickle

    markgrossnickle

    Joined:
    Aug 21, 2017
    Posts:
    32
    We pull MTX files from Bing to display 3D maps. The MTX files contain crunched textures that have been compressed by Microsoft.

    We can no longer load these crunched textures due to the updates in 2017.3. We get the following message:
    'The texture could not be loaded because it has been encoded with an older version of Crunch. This can happen when loading AssetBundles containing Crunch-compressed textures built with Unity version prior to 2017.3.'

    I don't believe Microsoft used Unity to crunch these textures (though I could be mistaken). In any case, we don't have access to the original files to crunch them anew.

    Any recommendations on how to continue using legacy textures?
     
  2. markgrossnickle

    markgrossnickle

    Joined:
    Aug 21, 2017
    Posts:
    32
    A bit more detail. The library we use points to an older version of https://github.com/BinomialLLC/crunch which I believe is what Unity is using. The format we are receiving is .CRN and it was working with:

    Texture2D texture = new Texture2D(width, height, TextureFormat.DXT1Crunched, false);
     
  3. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,144
    Have you tried opening them with an older release of Unity? If they work with an older release you can export them as a normal image format and then import them into the newer release.
     
  4. markgrossnickle

    markgrossnickle

    Joined:
    Aug 21, 2017
    Posts:
    32
    They work in order versions of Unity just fine. However, we don't have permission or the resources to update every Bing3D map tile. Thanks for the suggestion though!
     
  5. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,657
    We are using an updated version of Crunch which is faster, has better compression ratios, and supports more platforms/formats. Unfortunately that meant dropping support for loading the older version.

    Your best bet is probably to create a native plugin in C/C++, using the Crunch library directly yourself, to decompress the textures.
     
    markgrossnickle likes this.
  6. r3dwolf

    r3dwolf

    Joined:
    Feb 16, 2012
    Posts:
    39
    Hi, I have a similar problem too.
    Thanks @superpig for the suggestion.
    Is it possible to create crunched textures in the new format and load them in this way?
    Code (CSharp):
    1.     Texture2D texture = new Texture2D(width, height, textureFormat, false);
    2.     texture.LoadRawTextureData(www.bytes);
    3.     texture.Apply();
     
  7. r3dwolf

    r3dwolf

    Joined:
    Feb 16, 2012
    Posts:
    39
    I compressed some textures using the .exe in this GitHub repository but loading them with the code of my previous post I still get the error
    @superpig and @alexsuvorov can you help me?
     
  8. markgrossnickle

    markgrossnickle

    Joined:
    Aug 21, 2017
    Posts:
    32
    @r3dwolf you need to integrate the github project into your unity project. It requires creating a dll wrapper so you can make c++ calls from c#.