Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Bug Unity 2021.2.0b11 WebGL lighting and shadow inconsistencies

Discussion in '2021.2 Beta' started by PieterAlbers, Sep 15, 2021.

  1. PieterAlbers

    PieterAlbers

    Joined:
    Dec 2, 2014
    Posts:
    248
    Hi!

    I wanted to test out the WebGL updates and changes, but I quickly ran into the following issue.
    The lighting & shadows are incorrect. In the following image you can see the differences. Left is in Editor right are the WebGL.



    It seems the Directional Light is not as intense, and the brake lights and nitro lighting (see image) only shows up on the left (somtimes the right, depending on viewing angle). It almost seems like that light is being drawn below the shadows. It does feel a bit like there is a limit on the amount of lights and only the closest one is shown (it is not in the Pixel Light count settings btw)

    I can also see shadow problems when you drive down the track.


    The shader is a default standard shader with an albedo, 2 normal maps (one in detail).

    This is test project and there are no odd settings afaik. Quality and graphics are pretty much default.

    -Pieter
     
  2. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    I ran into this as well (in WebGL builds only). In my case it turned out to be an issue with loading normal map textures through Addressables. It took forever to figure out what was going on, including lots of dumb workarounds I tried related to normals and tangents, but eventually I stumbled on a tip which solved it. I'm not sure it's the same issue you're having but it's probably worth trying anyway - changing the importer settings to Default instead of Normal:
    https://forum.unity.com/threads/textures-not-displaying-properly-in-webgl-build.530546/

    The only pain related to the above that I've noticed is that you get warnings pop up telling you this or that texture is not set to be a normal map, and you have to click ignore or whatever - and it asks the same question about the same textures on occasion and you can't disable the warnings.

    Edit: I retested in latest, appears to be fixed (2022.2.0b2, URP 14.0.3, Addressables 1.20.3).
     
    Last edited: Jul 25, 2022
  3. PieterAlbers

    PieterAlbers

    Joined:
    Dec 2, 2014
    Posts:
    248
    Hi! Thanks for your reply!

    I can indeed confirm that setting the texture importer settings to Default fixed the issue. I am not using addressables though.

    This post by jukka_j is what I think is going on https://forum.unity.com/threads/textures-not-displaying-properly-in-webgl-build.530546/#post-5015276 Meaning the (standard) shader is incorrectly compiled. Other (custom) shaders show up fine. It would also explain why custom shader do work (as described in a post below that as well).

    Maybe something is off since we can setup Texture Compression in the Build Settings? Bug regression? Especially since this didnt happen at all in 2020.3.16 (which was the last version i used to build the game with).

    Anyway, setting the importer settings to Default is a workaround not expected behaviour so I do hope this will be addresed and fixed. I did alread log a bug report on this.

    -Pieter
     
    adamgolden likes this.
  4. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    In my case it's with Shader Graph shaders. I can't remember exactly which version I first noticed this, but if I had to guess I'd say it was later in the 2021 alphas.
     
    PieterAlbers likes this.
  5. PieterAlbers

    PieterAlbers

    Joined:
    Dec 2, 2014
    Posts:
    248
    We're not using URP for this project. Builtin with standard shaders and a bunch of custom ones.

    Were you using the lit node for your Shader Graph shaders?
     
  6. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    Yeah - in my case Lit as well. I don't think normals are used by Unlit shaders except for custom lighting systems or reusing the vertex data for something else. I knew it was something to do with lighting, it was just hard to work out what could possibly be wrong when it was fine in the editor and there weren't any errors. Along the way I also figured out that if I set tangents to Vector4.one, the seams would go away - but of course normals are lifeless without proper tangents.. which I also sort of learned thanks to this experience. I didn't think they mattered so much before and I often left mesh tangents null to reduce the size of mesh data - prior to seeing how much of a difference they make :rolleyes:
     
  7. PieterAlbers

    PieterAlbers

    Joined:
    Dec 2, 2014
    Posts:
    248
    I got a reply stating there is a fix for 2022.1 and a backport to 2021 is planned.
     
    adamgolden likes this.
  8. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    874
    Are you using WebGl 1.0 instead of 2.0?

    WebGl 1.0 is not compatible with linear rendering, and is generally obsolete.
     
  9. PieterAlbers

    PieterAlbers

    Joined:
    Dec 2, 2014
    Posts:
    248
    It's webgl 2.0 but also gamma.

    There are no visual issues when building the project in older (LTS) versions so this is definitely something for this particular beta.

    Thankfully a fix should be backported.