mpv icon indicating copy to clipboard operation
mpv copied to clipboard

vo_gpu/vo_gpu_next: overhaul alpha related options

Open Dudemanguy opened this issue 1 year ago • 3 comments

A spiritual successor to #9621 but it also implements vo_gpu_next support. This depends on this libplacebo MR.

This splits --alpha into two options: --alpha and --blend. alpha strictly controls whether or not draw the framebuffer with the alpha component if possible (default yes). blend is what controls blending the alpha component into either tiles, the background color, or nothing. This makes it possible to blend with a partially transparent background color e.g. something like mpv --background=0.5/0.5 --blend=background image.png.

I set the default blend to no so by default you actually get a transparent image when you open one. Didn't really see a reason to not try to open transparent images with transparency, but we can set it back to tiles if that's preferred.

TODO:

  • [x] The vo_gpu colors are wrong when blending with transparency for some reason. It kind of works (which is better than not working at all), but haven't figured out what I'm missing. Fixed.

Edit: Nevermind. The alpha component in --background is bugged in vo_gpu period. --background=0.5/0.0 is not fully transparent and has a light grayish color for whatever reason. It's fully transparent in vo_gpu_next as expected. ~Probably won't bother fixing vo_gpu here but if someone wants to, feel free.~ Should work now.

Dudemanguy avatar Feb 16 '24 22:02 Dudemanguy

Download the artifacts for this pull request:

Windows
macOS

github-actions[bot] avatar Feb 16 '24 22:02 github-actions[bot]

--background=0.5/0.0 is not fully transparent and has a light grayish color for whatever reason.

Looks like the window system expects pre-multiplied alpha for blending. If the color isn't alpha pre-multiplied it will look wrong. Maybe vo_gpu isn't pre-multiplying background alpha in this case.

na-na-hi avatar Feb 17 '24 00:02 na-na-hi

Oh yeah that's all it was thanks.

Edit: Should be fixed now.

Dudemanguy avatar Feb 17 '24 01:02 Dudemanguy

Now depends on https://code.videolan.org/videolan/libplacebo/-/merge_requests/640. I changed the name of some options as well. background -> background-color, etc.

Dudemanguy avatar Feb 21 '24 17:02 Dudemanguy

The API changes have been merged into libplacebo now so unmarking the draft status.

Dudemanguy avatar Feb 22 '24 15:02 Dudemanguy

Rewrote it to remove --alpha completely since it's useless and exactly the same as setting --background=color in practice. I also realized that I was setting want_alpha incorrectly before so it should hopefully be correct now.

Dudemanguy avatar Feb 22 '24 19:02 Dudemanguy