- Home /
Chrome webgl not working / flashing
I try to get a unity => webgl export working with transparent background on google chrome browser.
It works fine on firefox but on Chrome the background is not transparent, it seems dirty and sometimes even flickers super fast (which could be very dangerous for epilepsy people)
See video: https://youtu.be/qpTq73ZL5_c (do not watch if fast changing images can trigger epilepsy)
This is the code that should do the transparent background:
var LibraryGLClear = {
glClear: function(mask)
{
if (mask == 0x00004000)
{
var v = GLctx.getParameter(GLctx.COLOR_WRITEMASK);
if (!v[0] && !v[1] && !v[2] && v[3])
// We are trying to clear alpha only -- skip.
return;
}
GLctx.clear(mask);
}
};
mergeInto(LibraryManager.library, LibraryGLClear);
the code was taken from here: https://answers.unity.com/questions/1069255/embed-webgl-in-webpage-with-transparent-background.html
Please help, thank you!
EDIT: I thought it was caused by the above code. Unfortunately it is not the issue. I tried building and running the same without the transparent background and I got a similar issue, see: https://youtu.be/271mZsizvps
Answer by chitzui · Feb 13, 2018 at 10:19 PM
Ok I finally got it working see: https://forum.unity.com/threads/webgl-with-transparency-on-the-cavas.327425/
Basically, I think, the problem was that I did not have 0, 0, 0, 0 for the background color on the camera in unity.