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: https://funix.it/virtualexpo/ (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:
Hi!
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 UnityWebRequestTexture.GetTexture(). 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 UnityWebRequestTexture.GetTexture() 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?