Search Unity

Question Webgl textures compession support

Discussion in 'Web' started by ArtyomOverchuk, Apr 13, 2023.

  1. ArtyomOverchuk

    ArtyomOverchuk

    Joined:
    Nov 5, 2018
    Posts:
    6
    When trying to run a build with astc-compressed texture on a desktop browser, the message "RGBA Compressed ASTC12X12 UNorm format is not supported, decompressing texture" appears in the console. But "caniuse" and other sources say that modern desktop browsers support WEBGL_compressed_texture_astc. At the same time visually the picture looks compressed. How can you be sure if compression is being used on a texture?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,892
    It's not enough for browsers or WebGL to support it, Unity must also support this format as well.

    The picture looks compressed because it was compressed with a lossy compression. Uncompressing it only expands its size in memory but it will not add the details back that were lost upon compression. ;)
     
    ArtyomOverchuk likes this.
  3. ArtyomOverchuk

    ArtyomOverchuk

    Joined:
    Nov 5, 2018
    Posts:
    6
    Thanks for the answer. Do I understand correctly that those compression formats that are supported by desktop browsers are not supported by mobile ones and vice versa? Is it possible to make a Webgl release that works optimally on both platforms? Taking into account the fact that the graphics are stored in bundles and the compression settings from the Player settings are not applied (if I understand correctly)
     
  4. KamilCSPS

    KamilCSPS

    Joined:
    May 21, 2020
    Posts:
    448
    If that's the case, why not create & load different bundles per platform to support their respective compression?
     
    ArtyomOverchuk likes this.
  5. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,892
    I can't say for sure but it wouldn't be unusual for mobile web browsers to support other types of formats than desktop, and for mobile vs desktop to have different preferred formats. If in doubt it should be the lowest common denominator. Refer to this page. In case of ASTC it states that it isn't supported on desktop, only on mobile and webgl.

    What I was pointing out is that even if WebGL supports a given compression format, Unity would have to support it too.
     
    ArtyomOverchuk likes this.
  6. KamilCSPS

    KamilCSPS

    Joined:
    May 21, 2020
    Posts:
    448
  7. ArtyomOverchuk

    ArtyomOverchuk

    Joined:
    Nov 5, 2018
    Posts:
    6
    Thanks for the answer. Is there a way to create bundles in two versions for Webgl? For Unity Webgl, desktop and mobile are one platform. Especially when it comes to a project with a lot of graphics and hundreds of bundles

    Do I understand correctly that this method works if you do not use the Override for Webgl option? Or this is work only with resources in build and not bundles?
     
    Last edited: Apr 13, 2023
  8. RC_LCPH

    RC_LCPH

    Joined:
    Aug 16, 2023
    Posts:
    8
    Hi,
    I also have the same problem, I am trying to use the ASTC compression option both in the build settings and in the Payer Settings, and I get the same Warning on the Browser console (tested on Edge and Chrome): "WARNING: RGBA Compressed ASTC6X6 UNorm format is not supported, decompressing texture"
    According to Unity's documentation the compression format is supported https://docs.unity3d.com/2022.3/Documentation/Manual/class-TextureImporterOverride.html at the bottom of that documentation page there is a link Additional resources Texture compression in WebGL mid-page it list browsers support and that includes Edge and Chrome.
    Any help on how to solve this problem would be highly appreciated.
     
  9. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    Desktop GPUs don't support ASTC.
     
  10. RC_LCPH

    RC_LCPH

    Joined:
    Aug 16, 2023
    Posts:
    8
    Hi,
    Thanks for your reply, I have now tested it on a server and it still sending the same message, but I guess it then depends what type of server?
    In any case it would be a good idea to include any restrictions on the support of this compression format.
    If there is anyway to support the format from a server (windows virtual machine), I would appreciate the information.
     
  11. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    The server doesn't matter, that's not how GPU texture compression works. It's not like web data compression like brotli or gzip. It's more like video codecs: the client needs to support that specific codec to play it properly.

    Unlike a zip, png or jpeg file, compressed textures formats are loaded directly into the GPU. Their main purpose is to reduce the used video memory and GPU memory bandwidth, not file size or network bandwidth. All GPU texture formats have fixed compression ratios (unlike JPG or PNG images which compress differently depending on the image contents) because this allows random access without prior decompression.

    Desktop GPUs only support DXT formats. Mobile GPUs only support ASTC (Apple, Android 8+) or ETC (Android). This means that there isn't a single compressed format that works everywhere. This page shows an example of making separate builds with different texture compression overrides for mobile and desktop: https://docs.unity3d.com/Manual/webgl-texture-compression.html

    I never tested it, but I imagine the override also applies when building bundles. Change the override, build bundles for desktop, change again, build for mobile.
     
  12. RC_LCPH

    RC_LCPH

    Joined:
    Aug 16, 2023
    Posts:
    8
    @Neto_Kokku thanks for the clarification, I can see I totally misunderstood what you meant by desktop GPU.
    Your explanation is great. Unfortunately I was testing on iPads and using the Settings > Safari > Advanced and toggle on Web Inspector connecting to my Mac's Safari > Preferences > Advanced and check Show Develop menu in menu bar, to see the console logs from the iPad's Safari and still got the same warning of ASTC not supported, decompressing..., could this be correct?
    I am a bit confused by this because on the small demo I ran on an iPad Mini 4 (2 GB RAM) the only thing that ran was the unity loading screen in a loop, but once that I put the setting of texture compression to ASTC then it ran properly, could in this case the Web Inspector warnings incorrect?
     
  13. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    Interesting, I did some searching and the iPad Mini 4 should support ASTC. It could be a bug in Unity or maybe Safari doesn't report it as a supported format. You can open this site on your iPad to confirm what texture formats it supports: https://toji.github.io/texture-tester/

    Anyway, that warning won't prevent your game from running or showing the textures. What Unity does when the device doesn't support the format the textures were built with it decompresses the textures on the CPU into 32-bit RGBA textures before sending them to the GPU. So your game will run and look the same, but the textures will use more RAM (4x or more compared to their compressed versions).
     
    alan10801 likes this.
  14. unityruba

    unityruba

    Unity Technologies

    Joined:
    Nov 6, 2020
    Posts:
    272
    I implemented texture compression support almost two years ago :D so it'll make me sad if there's a bug in there!

    One thing to check is to open the javascript console for your web application and type in:

    Code (JavaScript):
    1. gl.getExtension("WEBGL_compressed_texture_astc");
    and see if that returns a value or if it returns null. That'll tell you if Safari on your iPad mini thinks that ASTC is supported. You can also see all the supported extensions by running:
    Code (JavaScript):
    1. gl.getSupportedExtensions()
    2.  
    For example here's a screenshot of what I see when I run it in my Unity application in Chrome. You'll see "WEBGL_compressed_texture_s3tc" in there, which exposes DXT5, and that makes sense since I'm using a desktop browser.

    Do share what you get, and if the browser supports ASTC but Unity says no, then there's a bug that we should look into and fix!
     

    Attached Files:

    OmarVector likes this.
  15. RC_LCPH

    RC_LCPH

    Joined:
    Aug 16, 2023
    Posts:
    8
    Hi again, thanks so much for the additional information and the link to confirm the supported compression format is great!
    We are trying to reduce the amount of RAM used that is why it is not ideal that the textures get decompressed, but all this information will help with the process a lot, thanks so much.
     
  16. RC_LCPH

    RC_LCPH

    Joined:
    Aug 16, 2023
    Posts:
    8
    Hi,
    Thanks also for this information, I will test this on Monday and let you know what I see :)
     
  17. RC_LCPH

    RC_LCPH

    Joined:
    Aug 16, 2023
    Posts:
    8
    Hi again,
    sorry for the delay, I still need to make the final test tomorrow with the same settings I had when I saw the warning in the web inspector. I will let you know the result tomorrow as soon as I get the results. :)
     
  18. RC_LCPH

    RC_LCPH

    Joined:
    Aug 16, 2023
    Posts:
    8
    Hi,
    all test I have ran so far on different iPads the compression ASTC is detected and I don't get the warning, in the test were I got the warning was from a test server, which in principle it shouldn't affect, but I was asked to rule complete out the possibility of a bug that I run the test from an identical server as our production one. So I will send you the final result of that test as soon as its done.
     
  19. RC_LCPH

    RC_LCPH

    Joined:
    Aug 16, 2023
    Posts:
    8
    Final test,

    Hi again, after long wait, I have finally managed to test our application from a cdn server and I am happy to report that it behaved as expected on the tablet's browsers, it detects the right supported extensions and there was NO WARNING of the texture compression ASTC not being supported.

    Thanks again for your friendly help @Neto_Kokku and @unityruba
     
    unityruba likes this.
  20. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,269
    For future reference this seems to be covered in the docs here: Unity - Manual: Texture compression in WebGL (unity3d.com) with examples, but it sure is a bit cumbersome to support mobile and desktop like this, perhaps with 2023/6 increased support for mobile there will be a more automated solution?!