WebGL2/Deffered_path/Dir lights not working

Issue with lights not working after switching rendering path from Forward to Deffered:

Unity 5.4.0b16 (64-bit), WebGL platform on WebGL2 standard (OpenGL ES3)
Checking with latest Firefox

Using Forward, scene looks almost identical as in Editor when previewed in browser.
Switched to Deffered, scene lights (3 of them, dir/spot/point) don’t affect geometry.

Any suggestion where could be the problem?


Update:
Issues definitely connected to Directional lights only. Deffered works perfectly well with multiple point and spot lights in scene. Adding Dir light causes all lights to stop working and skybox artifacts.

Probably connected to fact that Dir. lights have different implementation then other lights in Lighting stage of Deffered path: point and spot lights pass a stencil test (depends on implementation) based on their shape and range to detect affected pixels while Dir light is applied as a full screen quad to G-Buffer contents.

Anybody with more info hopefully?

I haven’t seen problems with Deferred+Directional lights before.
Have you tried the latest Beta ? If it’s still reproducible with Beta20, it would be great if you could submit a bug report with a repro project (and post the bug # here).

BTW, does it work in WebGL1.0 ?

I confirm the issue as RESOLVED with latest beta, Unity 5.4.0b20 (64-bit).
Same project updated to it, scene built and tested, all lights work in Firefox.

Still don’t know what caused the issue with previous version and Dir light in our scene.
As for WebGL1.0, I have not tried, if it can help you in tracking, I will do it.

Unfortunately, I need to reopen the issue and raise problem again.
To disclaim previous post: Beta20 was only fallbacking to Forward, not fixing problems with lights not working in Deffered rendering mode. I discovered this by attaching a script that logs current Camera’s rendering path to Firefox Java console.

So once again:
In Beta16 (and possible later ones), switching to Deffered makes all scene lights not work if there is a Directional light in the scene. Explained earlier, here is a new very simple example, left part editor view, right part Firefox with WebGL2 flag enabled:

UPDATE for latest Beta21: fresh project > Rendering path set to Deffered > Camera set to Rend. path: Player settings > Script logging ‘actualRenderingPath’ attached on camera > in Editor, console logs DefferedShading >those few cubes in scene built into both WebGL1 and 2 apps > latest Firefox shows that in browser scene camera fall backs to Forward

This happens both with OpenGL2 and OpenGL3.
@Marco-Trivellato
Should I submit you a bug report with small repro project? Even though it’s all fresh Unity Beta21 and latest Firefox, on Windows 7 64bit.

We had to disable deferred rendering on firefox and chrome on windows because of incorrect lighting. Once this is fixed, we will re-enable it.

OK, thanks for info!
If you’ll need more testing, would be glad to participate.

1 Like

@Marco-Trivellato
Any updates on what is happening with Deffered rendering path in WebGL1?

Latest beta 5.4.0f1 projects: cameras set to render through Deffered path still fallback to Forward in both latest Chrome and Firefox.
Latest stable 5.3.5f1 projects: cameras set to render through Deffered path use it in Firefox but fallback to Forward in Chrome.

OK, it seems that having ‘WebGL 2.0 Prototype’ flag enabled in Chrome messes up the situation and does not allow Deffered rendering to work on Chrome with WebGL1 content.

Camera set to render in Deffered mode will render with it in Chrome/Firefox when built with latest release Unity. Enabling WebGL2 content in those browsers makes two errors in Chrome:

  • WebGL1 content to fallback from Deffered to Forward path
  • Spotlights with shadows deactivate themselves in WebGL1 (bug reported, waiting for repro)

When it comes to latest beta, Deffered still does not work in WebGL1 builds on Chrome/Firefox