Search Unity

Resolved Webgl Lightmap bad color rendering

Discussion in 'Web' started by I7barkan, Feb 20, 2021.

  1. I7barkan

    I7barkan

    Joined:
    Sep 14, 2015
    Posts:
    7
    Hi everyone,

    I have a problem with the lightmaps of my project in WebGL.

    Normally my lightmaps look like this (platform : windows):


    But when I switch to WebGL the lightmap render change to become this:


    In inspector :



    Lightmaps files in webGL seem very heavily compressed with too contrasting colors.

    I thought it was a lightmap compression format issue. I have tested overriding for WebGL with all the compressions available, without success.


    I know GI is not supported in webGL, so my scene is in baked light mode. Here are my parameters :



    Do you have any idea what is causing this poor quality?
    I work on Unity 2020.2.4f1 (Windows) with URP.

    Thank you in advance for your help.
     
    Last edited: Feb 20, 2021
  2. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    Does the issue occur with uncompressed lightmap textures?

    Web browsers do lack the support for BC6H float textures, and several other block compression formats. That makes me wonder if this is due to badness from DXT1, or something else. Is it possible to make the lightmap textures 32-bit float RGBA to test? That should avoid all compression. (though would certainly not be a good shipping format, since their size is quite huge)
     
  3. I7barkan

    I7barkan

    Joined:
    Sep 14, 2015
    Posts:
    7
    Indeed, without compression the rendering is perfect ! Well seen !



    As you say it is not a satisfactory solution because the lightmap size is now very huge (85Mb per lightmaps, unusable online), but the problem is identified.

    Do you have any idea to compress these lightmaps in a format compatible with webgl ?

    Thank you !
     
  4. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    In the current Unity versions, using half-float RGBA might be best (64 bits per pixel), or RGB9E5 (32 bits per pixel, WebGL 2 only).

    When checking light map size on disk, take into account asset data compression (or gzip compression if using that). A 64 bits per pixel lightmaps should not use 4x space of 16 bits per pixel lightmaps, since the data should compress quite well for download.

    In the future if all goes according to plan, WebGL should add ASTC and other compressed texture format support in 2021.2. That would give compressed lower bpp lightmap support (~4 bits per pixel), although I am a bit unsure if with ASTC there will be a noticeable visual quality loss).
     
    elZach likes this.
  5. I7barkan

    I7barkan

    Joined:
    Sep 14, 2015
    Posts:
    7

    Indeed if I combine gzip compression and "lightmap encoding" in low quality the build goes down to 40mb and the colors are good. Thank you it works!



    So it's good to know: in WebGL builds lightmap must not be compressed (with unity <=2020.2)
    I hope 2021.2 will make progress on this.
     
    jukka_j likes this.
  6. unityruba

    unityruba

    Unity Technologies

    Joined:
    Nov 6, 2020
    Posts:
    273
    Hi @I7barkan , we added support for texture compression formats in 2021.2. You should be able to test your project now and use ASTC HDR compression formats for high quality lightmaps, as well as ASTC, ETC2, DXT for normal quality lightmaps. Please let me know if you run into any issues. :)
     
  7. I7barkan

    I7barkan

    Joined:
    Sep 14, 2015
    Posts:
    7
    Thank you ! that's excellent news