-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Semi-transparent objects in WebGL mode make the background behind them transparent #5451
Comments
Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already. |
This seems relevant: https://medium.com/david-guan/alpha-blending-and-webgl-823d86de00d8 |
I think I finally found a workaround based on https://webglfundamentals.org/webgl/lessons/webgl-and-alpha.html get a reference to the WebGLRenderingContext:
at the end of rendering each frame:
|
I think you should also be able to call |
Most appropriate sub-area of p5.js?
Details about the bug:
It appears the canvas background behind the cube (or other object) is not appearing (i.e. is completely transparent), and the transparency of the object is exposing the background of the webpage itself.
Here is an example that makes it very clear (no pun intended!), since I've specified a background image pattern in the css:
https://openprocessing.org/sketch/1309599
In this example:
The background image of the html page is set to be a repeating red "x"
The background of the canvas is a solid (no alpha) green
The color of the spinning cube and rect is (RGBA) color(255,80,180,150) -- note the "150" alpha value.
It appears the canvas background behind the cube is not appearing (i.e. is completely transparent), and the transparency of the cube is exposing the background of the webpage itself.
Indeed, even a PNG capture (hit 's' to saveCanvas()) has the same behavior, and the background of whatever you
look at the PNG on (a web browser, an OS image viewer, whatever) shows through in the area of the cube. (It does not in this example capture the "x"s, rather it preserves the transparency. Same happens with GIF capture with createloop.p5 or any capture with CCapture.js -- the issue is with the object itself as rendered in ps.j5)
Also attached two files -- the code is identical; only the background color of the underlying web page has changed (from white to black.) You can see the profound effect on the color of the object because the underlying color is showing through.
The text was updated successfully, but these errors were encountered: