WebGL build lighting issue


I am facing lighting issue in my WebGL build. Look at how the spotlight on the obstacle behaves when the rocket comes near it. That is what my issue is. This happens with spotlights only and not with point lights. This happens only in the WebGL build and not in editor. I ran my build in Chrome and Edge browser and in both i can see the same issue.

Any Idea how to fix it?

Hi Dhruv,

Unfortunately, I don’t know what might be causing this issue. Which version of Unity do you use? Have you already tried to rebuild your game?

Lighting in WebGL can be a bit tricky. The first thing I would try is to bake all non-moving lights to optimise the performance of the game. The less must be calculated during runtime, the better.


Hi Nina,

I am using Unity version 2018.2.6.
Yes, i have tried rebuilding the game multiple times but the issue persists.
Most of the lights in my game are non-moving lights and i am using spotlights most of the time.
As per your suggestion, i changed the mode of light to baked for my spot and point lights but when i make it baked, the editor is not even showing the illumination from the light. So, on running the game with baked spotlight light, there is no illumination from the light.

I noticed that the issue occurs whenever one spot light intersects with another. In my case, whenever the range and spot angle of spotlight from rocket intersects with other spotlights’ range and spot angle, the illumination from these other spotlights becomes invisible or turns off.

Based on the links you provided, can you confirm whether all objects are by default dynamic game objects or static?

Your observations are very helpful. Intersecting light sources are often a problem. That’s why I suggested to bake all static (= non-moving) lights. This way, the lights would not exist in your final scene anymore. Instead, the light becomes part of the texture as though you painted it on the blocks. The moving light source of the ship would interact with the texture only, not with another light source.

Make the all non-moving objects static in the Inspector. And set all non-moving light sources to static as well. Then go to Window > Rendering > Lighting and click on “Generate lighting”. The scene should look exactly as before. Then test your game.

If the issue persists, you could go to Edit > Settings > Quality and check if you can tweak some values or enable something. Since WebGL is a “weak” platform, try to aim for the lowest values with which your game still looks good. The lower, the better.

Then test your game again. It might be that some effects simply occur because the browser has so much to do.


See also:

Hi Nina,

As you suggested, i have made the non-moving objects and light sources as static. I have also baked the light source that is selected in the screenshot. After making these changes i clicked “Generate Lighting” but the effect of baked light is not visible in the the scene view and game view. I can see a folder created with lightmap data but no effects visible.
unity%20-%203_Project_Boost%20-%20WebGL_%20_DX11%20on%20DX9%20GPU_%2009-03-2019%2011_56_01
Even after build and run, it is not showing it.

Maybe you can find a solution in this thread:

https://forum.unity.com/threads/solved-lightmapping-not-working-with-lights.385246/

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms