I’m trying to figure out how to get blending modes to work by composing multiple layers, and sometimes it works, but sometimes the results are … weird.
As a test image, I draw a red rectangle and on top of it a smaller rectangle filled with a linear gradient from white to black using Multiply as blending mode. The code is arranged like this and the image looks as it should.:
What could be the reason for that? If I draw this on the screen in a loop, it looks like noise on a TV screen, since the pattern changes from frame to frame.
By the way, the image in my posting is the result of drawing off-screen and saving the color buffer to a file. But as I wrote, it looks similar when drawn on the screen, just changing with each frame. The same patterns appear when I wrap the red rectangle in a layer using Normal as blending mode.
This is how the test image looks (and should look) when I just draw the two rectangles using the code structure that I outlined in my posting:
I played around with more layers and found out that I can avoid the patterns by first moving the drawer.clear out of the composition, not using a layer for the “background”, i.e. the actual first layer that would use Normal as blending mode, and then using DestinationAtop wherever I would have assumed Normal would be the right choice.
Unfortunately, this only seemed to work for some simple tests, or I maybe didn’t pay enough attention. While I do not yet fully understand what DestinationAtop does, it is no replacement for Normal. Here is an example:
In the resulting image, the yellow rectangle is clipped at the borders of the red one, which it would not be when using Normal() which, even in this case, leads to the noise patterns.
Could this be an issue somewhere in my system stack, i.e. JVM, driver, OS etc.? I’m working on an M1 Mac, are there any known issue or is there some place where I could find something like that out?