-
-
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
Issues with Background Alpha/Transparency in WEBGL #4596
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. |
Hi, I have exactly same problem. I want to apply the fading out effect on point() by using alpha value in stroke(), but even I write like stroke(r, g, b, [some alpha value]), it seems not to work:( I'd like to know, is this because p5.js simply don't have the function or some kind of bug. |
I think it's the expected behavior as what you could do is to use p5.Graphics in WEBGL mode, and draw that graphics on top of 2d canvas |
I see now, thank you very much! Didn't cross my mind to do it that way. Hopefully others who have the same problem can see this as well. Maybe this could be an example on the website? |
This doesn't seem to work properly anymore on the latest version of p5js |
In p5 1.4.1, WebGL canvases were changed to not have an alpha channel by default to get more predictable blending: #5555 So now you have to manually specify when you want an alpha channel on your WebGL graphic. Try adding this after you create the graphic: pg.setAttributes({ alpha: true }); |
You additionally need to call |
Amazing, thank you! Looks much better now. I initially stumbled across this thread because I was trying to figure out why |
Most appropriate sub-area of p5.js?
Details about the bug:
Hello! There's an issue we're having on transparency in WEBGL. Using
background()
andfill()
with transparency doesn't work and produces a lighter color instead of blending properly. We've tried usingblendMode()
and the differentsetAttributes()
to no avail.Is this intended behavior in WEBGL? Or do we have to set something else to make this work? Just trying to figure out how to fade to a color in WEBGL.
Using
blendMode(MULTIPLY)
with a light grayfill()
seems to work, but this doesn't allow for other colors with the wayMULTIPLY
works.Thanks and have a nice day 😄
Here's another one using
fill()
Both examples ignores the alpha instead of fading to black just like it would in 2D.
The text was updated successfully, but these errors were encountered: