Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Baked lightmap not used in WebGL builds?

Discussion in 'Web' started by gecko, Mar 14, 2015.

  1. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,240
    My lightmaps are not being used in WebGL builds. Is that expected behavior? Attached are screenshots from a very simple scene -- in Editor on the left, in Firefox on the right. Plus my Lighting settings. In this scene, most of the light comes from an emissive material, which creates soft shadows and ambient occlusion.

    thanks
    Dave
     

    Attached Files:

  2. Doddler

    Doddler

    Joined:
    Jul 12, 2011
    Posts:
    269
    I couldn't get this to work in my WebGL builds either, it just keeps not applying lightmaps correctly, corrupting the lightmap, or just displaying things as black. Actually it keeps breaking in all build targets, but it seems even less workable in webGL.
     
  3. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,240
    Does anyone know definitively if this is something I'm doing wrong, or simply not supported by WebGL? @jonas echterhoff?
     
  4. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,070
    Enlighten Lightmapping is not supported by WebGL (afaik).
     
  5. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,240
    Thanks! Wow, so there's no way to have lightmaps in WebGL? That seems worth noting in the documentation somewhere....
     
  6. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Actually, Lightmapping should work in WebGL. However, realtime GI is not supported - so in your lighting setting, make sure that realtime GI is disabled before you bake.
     
    ba55yunky and vuthang like this.
  7. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,240
    Oh so glad to hear that, Jonas!

    Realtime GI is disabled, but lightmaps are not working in the webgl build. Should I submit a bug, or do you see something wrong in my settings (attached to my first post).
     
  8. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Submit a bug and post the case number here, then i can have a look.
     
  9. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,240
    I've submitted a simple test project, case #683488

    thanks!
    Dave
     
  10. mospheric

    mospheric

    Joined:
    Apr 12, 2013
    Posts:
    1
    I've been getting the same issue. Seems lightmaps are breaking when building to WebGL. Have there been any updates on this issue?
     
  11. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    I took a look at the bug report, thanks. It seems that there is indeed a bug - which is that directional lightmaps currently don't seem to work in OpenGL ES 2.0 (which includes WebGL). Our lightmapping team is looking into this - Until then, you can switch lightmaps to non-directional, which should work in WebGL, too.
     
  12. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    972
    I have to change all the shaders to Legacy in order to get the enlighten lightmaps to work.
    But I am still not happy with the artifacts, especially around thin edges.
    The Beast used to bake faster and to provide more predictable and smoother results.
    Here is an example of what I am getting:
    http://virtualplayground.d2.pl/WebGL/st15/?ep_A26_heinz
     
  13. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,240
    @jonas echterhoff : Switching to non-directional lightmaps did the trick, thanks! And I can live with that for awhile.
     
  14. Kuba

    Kuba

    Moderator

    Joined:
    Jan 13, 2009
    Posts:
    416
    The issue is with the Standard shader, not the directional lightmaps per se. For the time being you can just switch to the non-directional mode and then the Standard shader will work just fine (and will give better results than what you have with legacy shaders).

    Those artifacts look insane. They look like jpeg artifacts though, I doubt they come from DXT compression or from Enlighten itself. Could we have a repro case, so we can check what's up?
     
  15. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    972
    It would be great if you could take a look. I have reported that as a bug, together with the project/scene files.
     
  16. Kuba

    Kuba

    Moderator

    Joined:
    Jan 13, 2009
    Posts:
    416
    Could you provide the case number here? I only see some old bug reports submitted with your e-mail.
     
  17. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    972
    I have just noticed that these artifacts appear only when directional specular lightmaps are selected.
     
  18. rstorm000

    rstorm000

    Joined:
    Aug 19, 2010
    Posts:
    229
    Will directional ever come in?
     
  19. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    The lightmapping team says that they have it on their roadmap, but are currently busy with other bugs, so no ETA.
     
  20. TkachenkoRA

    TkachenkoRA

    Joined:
    Dec 14, 2015
    Posts:
    1
    Hey. I would like to know whether the works are carried out to eliminate errors lightmap in WebGL?
     
  21. prawn-star

    prawn-star

    Joined:
    Nov 21, 2012
    Posts:
    76
    Hi

    I'm using Unity 5.3.3 and having no luck with the baked GI lightmap on the standard shader.
    When I bake I get the Lightmap-0_comp.dir and Lightmap-0_comp_light images but they do not seem to be applied to any object in my webGL scene.

    Is there a simple project somewhere that has baked GI working for webGL.
    Maybe if I could see how that is set up I could try and figure out what is wrong with my settings

    regards

    Paul
     
  22. prawn-star

    prawn-star

    Joined:
    Nov 21, 2012
    Posts:
    76
    I think I found the problem
    I had a couple of lights in the scene set to realtime
    Once I turned them to baked then the light maps appeared
     
  23. Matheus-Crivellari

    Matheus-Crivellari

    Joined:
    Dec 28, 2015
    Posts:
    1
    I've got a simillar problem. I was working with Unity 5.4.1f1 and my WebGL build had nice lightmaps as expected. Then after upgrading to Unity 5.5.1f1 my WebGL builds got no lightmaps at all and no skyboxes.

    I've come to fix the skybox problem changing it from "6-sided Skybox" to "Cylindrical Cubemap Skybox" (what also solved a problem with the weird Skybox Texture's seams).

    As prawn star did and said, I also tested turning my Directional Light to "Baked" and baking the lightmap again, then I got Lightmaps. But then I got no dynamic shadows onto static objects and vice and versa, so that's not interesting to me.

    Then I tried baking once again with my Directional Light set to Realtime and the thing is: Into Unity Editor I got lightmaps. And testing the WebGL build in Firefox I got correct lightmaps. But testing it in Chrome, theres no lightmaps at all.

    I thought it could be my Chrome version, but it is identical to a friend's Chrome version, and in their Chrome my WebGL build just works fine (with lightmaps).

    I tried also updating my video card driver in hope that it could have something to it, but I had no success. Tried, also, reinstalling my Chrome, but the problem seems not be with that.
     
  24. highpockets

    highpockets

    Joined:
    Jan 17, 2013
    Posts:
    71
    I had the issue where I baked my lightmap in blender and imported it to unity as a "Lightmap" texture (in the import settings) and everything worked fine on pretty much all other platforms except for Web GL. Just in case you have the same issue, I just changed the custom blender baked lightmaps to "Default" in the import settings and now everything works fine and dandy. Cheers
     
    arumiat likes this.
  25. highpockets

    highpockets

    Joined:
    Jan 17, 2013
    Posts:
    71
    Actually, I just noticed that the same is true for building on iOS, cheers
     
    arumiat likes this.
  26. Elin42

    Elin42

    Joined:
    Oct 21, 2014
    Posts:
    22
    So in 2019.2 its still not possible to use baked lightmaps in asset bundles on WebGL with unitys default light mapper?
     
    SerchRadd, LaurieAnnis and Twyker_gp like this.
  27. doctorpangloss

    doctorpangloss

    Joined:
    Feb 20, 2013
    Posts:
    270
    I am using baked lightmaps with the default light mapper in a WebGL 2019.2.0 build right now, but not in asset bundles, which are very glitchy in WebGL and basically unusable.
     
    Twyker_gp likes this.
  28. Erjetto

    Erjetto

    Joined:
    Apr 25, 2018
    Posts:
    1
    Just wanted to add my own solution with baked lightmaps bug when using URP project to create WebGL games, which is by unchecking Compress Lightmaps. I'm also using Subtractive Lighting Mode, Progressive CPU Lightmapper and Non-Directional mode.

    This is what it looks like before I unchecked it. I haven't seen anyone experienced this so I'll put it here...
     

    Attached Files:

    obeycmb and jason-vreps like this.
  29. jason-vreps

    jason-vreps

    Joined:
    Sep 22, 2017
    Posts:
    16
    @Erjetto ran into exactly what you're experiencing. Thanks for your post! Helped solve my lightmap issue. Specifically, we were using gzip with compression ON, and changed up our website. As a result we had to turn gzip off, but had left compression on. This combination (webGL gzip compression off, lightmap compression off) turned our WebGL deployments into a disco lightshow (like your image), but ONLY on Safari! All other browsers worked fine.

    Turned lightmap compression off, and we're back to normal.
     
  30. obeycmb

    obeycmb

    Joined:
    Feb 16, 2021
    Posts:
    2
    This worked for me, thank you so much! :D
     
  31. GoinPlaces

    GoinPlaces

    Joined:
    Nov 15, 2017
    Posts:
    13
    In Unity 2021 this bug is still there. Do you know about any future fixes?

    Our issue is the following: Our scenes will be used in Windows/MacOS Builds as well as WebGL. We have a "lights off" function that replaces lightmaps and cubemaps in realtime (prebaked ones for the darker room), disables mixed lights, lightprobes (ambient light is used instead) and emissions of lamp materials. So far so good. Everything worked out in the standalone build so far, but in WebGL we are getting these annoying errors.

    When we bake everything non-directional it works in WebGL too! (albeit without nice specularities, but that is acceptable for WebGL)

    However, we want the directional maps for the Windows/MacOS builds, and non directional for WebGL. Telling Unity to just not use the directional lightmaps (by not setting LightmapData.lightDir) doesn't work. It seems to be determined by the light setting that the scene has? How do I fix this? I don't want to have to apply everything every time I make a build for EVERY scene.

    Is there a way/solutions to kind of adjust the lightsetting/directional/non-directional setting for the respective builds?
     
    GDevTeam likes this.
  32. liambilly

    liambilly

    Joined:
    May 13, 2022
    Posts:
    154
    was this issue not addressed my webgl build broke after generating lightmap. using unity 2022