Search Unity

Bug ASTC compression and UnityWebRequest

Discussion in 'Web' started by DudoTheStampede, Feb 21, 2023.

  1. DudoTheStampede


    Mar 16, 2015
    Good morning,

    our adventure in the fabulous world on Unity WebGL brought to another unexpected problem!

    Tl;dr: why an ASTC compressed file downloaded via a UnityWebRequest (on a mobile device only) gives "WARNING: RGB Compressed DXT1|BC1 UNorm format is not supported, decompressing texture" when loaded into a texture?

    The long explanation:
    We created a platform for our clients to load their content (image/text/3d models) in a premade 3d environment. You can see it in action at: (our digital portfolio made using the same platform).
    We are striving to lower downloading and loading time both in desktop and in mobile devices.
    Until yesterday all the texture where compressed in DXT format, good for desktop but on mobile it lead to "WARNING: RGB Compressed DXT1|BC1 UNorm format is not supported, decompressing texture".
    So now I made two different build with two different texture compression (DXT for desktop, ASTC for mobile) and serve it based on the user device.
    So far, so good.
    Sadly I've another problem (the one addressed in the title!). Part of the resources are loaded by the client on a web-based dashboard (like a Wordpress website). If you open the link I gave you before, you can see different images on some walls. Those are not part of the build but they are downloaded in Unity through a UnityWebRequest and loaded as texture where they are needed. Those resources are ("were", but we are getting there) simple jpg files and they give the DXT warning from before everytime they are loaded!
    To try to prevent that now when the client load the jpg file on the dashboard I made an ASTC compressed file and, only on mobile, I load that insted of the jpg.
    If I try it in editor I can correctly see that the generated texture are ASTC compressed (and the JPG ones are DXT, so it seems to work). When I do that online (with the device inspector connected to my computer) in the console I still see the same warning! Obviously (not) if I load the ASTC compressed file in a desktop browser it gives me the Warning because the texture is ASTC compressed and the computer doesn't support that! :S

    I disabled the mipmaps but nothing changed. Here is how I create the texture:
    Code (CSharp):
    1. Texture2D downloadedTexture = new Texture2D(width, height, TextureFormat.ASTC_8x8, false, true, true);
    2. downloadedTexture.LoadRawTextureData(byteArray);
    3. downloadedTexture.Apply(false, true);
    Am I missing something or this is a bug? Is that a way to make it work like I want to?
    Last edited: Feb 21, 2023
  2. nxtboyIII


    Jun 4, 2015
    hey did you ever figure this out?
  3. MarcelPursche


    Unity Technologies

    Mar 3, 2021
    Can you give me a bit more information on your project? You did a build optimized for desktop(using DXT texture compression) and for mobile(using ASTC texture compression). Are you setting the default texture format using the drop-down in the Build Settings Window or are you changing it in Player Settings -> Other Settings?
    You tried to load a jpg image as a texture using
    . Is that right?
    On the desktop build this will recompress the jpg file to DXT as expected but on the mobile build it also tries to do DXT compression(although ASTC is the default texture format)?

    I looked into
    at it seems like it only supports on-the-fly compression for DXT formats. But it should leave the texture uncompressed if the texture format isn't DXT. So this is potentially a bug.

    Your workaround with loading already ASTC compressed textures did not work in a Web build? How are you loading the raw texture data?