Search Unity

Textures not displaying properly in WebGL build

Discussion in 'Web' started by Spartan301, May 8, 2018.

  1. Spartan301

    Spartan301

    Joined:
    Aug 31, 2011
    Posts:
    20
    Hello, we are currently working on adding web support to our application and are struggling with an issue where the textures and lighting of a 3D model are not displaying properly in a WebGL build. The top image is what we see in the editor, the bottom is what we see in the build.







    Some additional info:
    • All models are loaded from an asset bundle
    • All textures do not have any import settings overwritten for WebGL and are set to the default "Low Quality" compression level.
    • Mip maps are enabled
    • The Standard Specular shader is used
    • All models have a main texture and a normal map
    • The transparent skin is not a transparent texture but instead faded down using the alpha value of the albedo color
    • We are using Unity 2017.1.0p3
    If y'all have any idea what might be causing this I would appreciate any help you can give.
     
  2. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    Which browser? If it's Chrome/Firefox, maybe try Edge/Safari.
    Any shader error in the browser log?
    You could also try to have a look at in in Spector.js
     
  3. Spartan301

    Spartan301

    Joined:
    Aug 31, 2011
    Posts:
    20
    We have the same issue in all browsers that we've tested (Chrome, Firefox, Safari). No shader errors in the log, but ill look into using Spector.js
     
  4. Spartan301

    Spartan301

    Joined:
    Aug 31, 2011
    Posts:
    20
    I looked at the Spector.js snapshot, but am not familiar with OpenGL enough to be able to get any usable information from it. Nothing jumps out as being a cause of the issue, just that everything is still rendering incorrectly in the capture buffers.
    The link to the capture output is https://drive.google.com/open?id=1POMkgubF2bGmBJBy3dJVid_s3BRqUUXZ if anyone is interested.
     
  5. Spartan301

    Spartan301

    Joined:
    Aug 31, 2011
    Posts:
    20
    So I believe I might have found the solution (or at least a workaround). The issue was with the normal maps, and switching the Texture Type on the import settings from 'Normal Map' to 'Default' fixed the issue. My hunch is that under the Default type RGB compression is used while under Normal Map on RGBA compression options were available which is something we don't need.

    This fix does however make me nervous as I would assume that the Normal Map setting would be correct and Im afraid that we will be missing out on something by using the Default texture type. Additionally all of our materials would have a message on them saying "This texture is not marked as a normal map Fix Now" even though clicking that button would actually break our web builds.

    Does anyone have any input on this? This seems like a workaround and I'd like to have a proper fix in place for this issue. Some additional info on the normal maps themselves they are exported from 3DCoat into photoshop which then exports them as jpgs.
     
    Twyker_gp likes this.
  6. Twyker_gp

    Twyker_gp

    Joined:
    Dec 4, 2018
    Posts:
    29
    I have to necro this thread, as I seem to have the exact same problem, but only when I'm doing a WebGL build that loads the assets via the addressables system.

    Putting all normal maps into "default import" mode seems to kind of work (with small artifacts here and there) but this surely can't be the solution, right?!
     
    adamgolden, Jaimi and Pavel6625 like this.
  7. Pavel6625

    Pavel6625

    Joined:
    Aug 15, 2019
    Posts:
    3
    I have the same problem. Is there a solution better than found?
     
    Jaimi and Twyker_gp like this.
  8. Twyker_gp

    Twyker_gp

    Joined:
    Dec 4, 2018
    Posts:
    29
    Only sensible solution for me was exchanging the standard shader on everything that has normal maps with Legacy Shaders.


    @Marco-Trivellato
    Any other ideas how to get Standard Shader/Uber running again from bundles?
     
    Last edited: Sep 26, 2019
  9. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    There is a known issue that exporting to WebGL may incorrectly compile shaders in relation to using compressed texture formats if the shaders are present in the "Always Included Shaders" list in Project Graphics settings. Not sure if that is the bug here, though you can try checking if the badly rendering shaders in question are in the "Always Included Shaders" list, and if so, try removing them from there.
     
  10. Twyker_gp

    Twyker_gp

    Joined:
    Dec 4, 2018
    Posts:
    29
    I am also posting and following the thread you mean, but this also happens for us if the shaders are used on objects in asset bundles. So this is kind of the same problem, but has nothing to do with the always include list as far as I can tell.

    @jukka_j
    Edit: I just sent you the link to the open issue where I submitted a mini project with said problem.
     
  11. Twyker

    Twyker

    Joined:
    Nov 10, 2016
    Posts:
    12
  12. Twyker_gp

    Twyker_gp

    Joined:
    Dec 4, 2018
    Posts:
    29
  13. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    191
  14. Twyker_gp

    Twyker_gp

    Joined:
    Dec 4, 2018
    Posts:
    29
  15. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    191
    Twyker_gp likes this.
  16. Slock20969

    Slock20969

    Joined:
    Nov 18, 2015
    Posts:
    15
    Hate to keep "necro"-ing this thread........but I am running into the same problem. I made the simplest project ever, just a 2D Map that I can scroll around on. The Normal map is working but there's no albedo texture.
     
  17. nauroman

    nauroman

    Joined:
    Nov 1, 2014
    Posts:
    13
    I solved normal mapping issue by my own shader.
     
  18. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    191
    you came here to brag about it, or...?
     
    JeffreyBennett likes this.
  19. nauroman

    nauroman

    Joined:
    Nov 1, 2014
    Posts:
    13
    Sorry, but I don't think my shader could help - It's quite specific. I'm just saying that it is possible to recreate something like a default UnityShader with proper normal map behaviour.

    I wrote that shader for this project:

    Shader.png default shader .png demo.png
     

    Attached Files:

    SadGolem and OneManArmy3D like this.
  20. Twyker_gp

    Twyker_gp

    Joined:
    Dec 4, 2018
    Posts:
    29
    Hey, I just switched over to the 2020.1 Beta and it seems to be finally working in this version. :)
     
  21. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    191
    Hmm, on issuetracker page state is still "Active".
    I don't plan to use unity 2020 at least next 6 months. Hopefully they will soon apply fix in unity 2019 LTS.
     
  22. flipddr

    flipddr

    Joined:
    Jan 30, 2019
    Posts:
    3
  23. Twyker_gp

    Twyker_gp

    Joined:
    Dec 4, 2018
    Posts:
    29
    This should be fixed in U2020.1
     
  24. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    191
    And after almost a year, this bug report is closed with "Not Reproducible" :D
    Unity.... omg

    Edit: Turns out it's now fixed in 2019 LTS version. Thanks.
     
    Last edited: Jul 29, 2020
    Twyker_gp likes this.
  25. flipddr

    flipddr

    Joined:
    Jan 30, 2019
    Posts:
    3
    Wasn't fixed for me in 2020 or 2019.4.0f1. I'm using the Universal RP, and changing the material shader to URP/Baked Lit instead of URP/Lit finally did it. Hope this helps someone.
     
  26. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    This solution worked for me in 2021.2.0b6 for the exact same issue (WebGL builds + Addressable normal map textures). @jukka_j I tried your suggestion as well (sort of - in my case removing from a Shader Variant Collection).. no luck.