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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I only got it to work with the built in render pipeline. See https://docs.unity3d.com/Manual/class-Camera.html