You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The additive blendmode does not respect alpha under certain circumstances.
When the following code is run, the two circles drawn have 100% alpha, but we should expect them to have 50% alpha (set by 0x80). There are workarounds, explained below.
voidsetup() {
size(800, 800, P3D);
generate();
}
/*If the draw() function is removed, blending honors alpha, whether or not the last line of generate() is included.*/voiddraw() {
//
}
voidgenerate() {
blendMode(BLEND);
background(0xFF000000);
noStroke();
blendMode(ADD);
fill(0x80FF0000);
circle(300,300,400);
fill(0x8000FF00);
circle(500,500,400);
// If this last line is omitted, blending doesn't honor alpha.//blendMode(BLEND);
}
Workarounds
Blending will honor alpha as expected if one of these things is done:
Omitting the draw() function
Making sure to set the blend mode back to BLEND at the end of the generate() function
Drawing into a PGraphics buffer and then drawing this buffer to the screen as in this code:
Description
The additive blendmode does not respect alpha under certain circumstances.
When the following code is run, the two circles drawn have 100% alpha, but we should expect them to have 50% alpha (set by 0x80). There are workarounds, explained below.
Workarounds
Blending will honor alpha as expected if one of these things is done:
Environment
The text was updated successfully, but these errors were encountered: