Last active
August 11, 2023 07:44
-
-
Save thelucre/da56a5b22740eeb4116f to your computer and use it in GitHub Desktop.
Transparent WebGL Rendering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: http://forum.unity3d.com/threads/webgl-transparent-background.284699/#post-1880667 | |
// Clears the WebGL context alpha so you can have a transparent Unity canvas above DOM content | |
// Add this .jslib to your project et voila! | |
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); |
I can't make this work using Unity 2020 in URP as there is no clear flags for camera. any solutions?
I only got it to work with the built in render pipeline. See https://docs.unity3d.com/Manual/class-Camera.html
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't have any problems with this system and unity <= 2019, but if I try this workflow with unity 2020 It just doesn't work, anyone figured it out.