-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
WebGL background & clear odd behaviour #5195
Comments
Hi @JetStarBlues thanks for the thorough issue! I think this is due to subpixel rendering or antialiasing. If you look at your example in Chrome with I hesitate to say this is caused by p5 in specific. |
Thank you for pinpointing the issue! I guess I'm expecting that the color used for the anti-aliasing will correspond to the color of the object. For example in this case, the lime green would be used, but varying in opacity, to generate the anti-aliasing. And that the background color will play no role whatsoever. |
Hi! I think this should be fixed now as of #5917, as the weird blending with the background seems to only happen when premultiplied alpha is turned off. I'm going to close this for organizational purposes but feel free to discuss more or ask for this to be reopened if you notice anything weird still going on in the next p5 release! |
Most appropriate sub-area of p5.js?
Details about the bug:
Description of the bug:
When you try to clear the screen (with
clear()
orbackground()
), a weird subtle thing happens.Consider this snippet (live version here):
It should draw a box stroked with a lime-green color. However, in addition to the lime-green stroke, a ghost-like stroke appears in some regions that corresponds to the color used in
background()
orclear()
*. Here are some examples:clear
or black background with alpha zerobackground( 0, 0, 0, 0 )
detail of

clear
or black background with alpha zerobackground( 0, 0, 0, 0 )
red background with alpha zero

background( 255, 0, 0, 0 )
detail of red background with alpha zero

background( 255, 0, 0, 0 )
white background with alpha zero

background( 255, 255, 255, 0 )
detail of white background with alpha zero

background( 255, 255, 255, 0 )
. A red background has been added with an image editor for contrast.The effect does not seem to be unique to the stroke shader. The same effect can be observed with a filled box.
The bug seems to be triggered by using a color with an alpha that is not equal to
1
as an argument tothis.GL.clearColor
(clear implementation, background implementation).*Even though
clear()
does not take a color parameter, behind the scenes, the color (0,0,0,0) is used.The text was updated successfully, but these errors were encountered: