glue-viz / bqplot-image-gl

Jupyter widget for displaying images with a focus on astronomy
MIT License
19 stars 13 forks source link

Blending issue with multiple ImageGLs #105

Open astrofrog opened 1 year ago

astrofrog commented 1 year ago

The following notebook demonstrates a bug in the blending of multiple ImageGL marks:

https://gist.github.com/astrofrog/08735bc30c2f8980edeaae0fd0842352

In short, I set up two arrays that look like:

image1 = np.array([[[255, 0, 0, 255], [0, 0, 255, 255]], [[255, 0, 0, 0], [0, 0, 255, 0]]]).astype(np.float32)
image2 = np.array([[[0, 0, 255, 0], [255, 0, 0, 0]], [[0, 0, 255, 255], [255, 0, 0, 255]]]).astype(np.float32)

In both cases the top and bottom row of pixels is the same within the image except that the top row (in the first case) and the bottom row (in the second case) are transparent. If I show the arrays individually I get sensible results:

Screenshot 2023-07-11 at 21 25 42 Screenshot 2023-07-11 at 21 25 48

But if I show the two at the same time the result looks incorrect:

Screenshot 2023-07-11 at 21 25 55

It seems perhaps the alpha compositing is not correctly taking the opacity layer into account. I haven't had a chance to dig into the shader code yet.

pllim commented 1 year ago

Does this affect Imviz?

astrofrog commented 1 year ago

Not for now