Skip to content
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

vo_gpu: split 'alpha' into two options #9621

Closed
wants to merge 1 commit into from

Conversation

occivink
Copy link
Contributor

Currently it covers two somewhat orthogonal concepts:

  • whether to create a framebuffer with alpha component
  • how to blend video with alpha information

This commit creates a new flag 'fbo-with-alpha' which now controls
the first part, while 'alpha' now only covers the second.

Previously it would only be possible to make the window transparent
with 'alpha=yes', which prevented blending of the image with tiles or
the background.
This split allow using different blending strategies while keeping the
window transparent.

One downside is that only specifying 'alpha=yes' no longer makes sense
without specifying 'fbo-with-alpha' as well.

Fixes #9615
If this seems ok conceptually, I can adjust the docs and document the new flag.
Tested on wayland with wayfire (wlroots-based) and weston.

@occivink

This comment was marked as off-topic.

@haasn
Copy link
Member

haasn commented Dec 20, 2021

I think I would prefer naming this option something like "--window-transparent", to go with the other "--window-" flags.

@occivink
Copy link
Contributor Author

Updated the option name to window-transparent and moved it to options.c. I've also noticed that toggling window-transparent (or previously, switching alpha to/from yes) at runtime doesn't work, only the initial status of the option seem to matter. I'm not sure if this is meant to be a supported usecase, but I thought I'd mention it.

@Dudemanguy
Copy link
Member

It's because you added the option value to mp_vo_opts instead of gl_video_opts.

@occivink
Copy link
Contributor Author

Ok indeed. Does the option belong there? I added it to vo_opts since that's where others window- options were defined.

@Dudemanguy
Copy link
Member

Dudemanguy commented Dec 29, 2021

Setting the want_alpha flag is only ever going to work with gpu or gpu-next so I say it would belong with gl_video_opts and not generic mp_vo_opts.

@occivink
Copy link
Contributor Author

I put the option in gl_video_opts, added a warning for alpha=yes without window-transparent, and updated the documentation accordingly

@occivink
Copy link
Contributor Author

Added an interface-changes.rst entry (and also ping).

@occivink occivink force-pushed the gpu-split-alpha branch 2 times, most recently from a91ff5d to d36b557 Compare April 8, 2022 16:30
all platforms. If alpha framebuffers are unavailable, it silently falls
back on a normal framebuffer. Note that if you set the ``--fbo-format``
option to a non-default value, a format with alpha must be specified,
or this won't work. Whether this really works depends on the windowing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sentence about --fbo-format should go into the documentation of --alpha=yes, since it's relevant only for alpha blending within the pipeline, rather than display onto the screen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this? I'll admit that I don't full understand the workings of fbo-format, even after trying its different values out.

Currently it covers two somewhat orthogonal concepts:
* whether to create a framebuffer with alpha component
* how to blend video with alpha information

This commit creates a new flag 'window-transparent' which now controls
the first part, while 'alpha' now only covers the second.

Previously it would only be possible to make the window transparent
with 'alpha=yes', which prevented blending of the image with tiles or
the background.
This split allow using different blending strategies while keeping the
window transparent.

The special value window-transparent=auto is created for backwards
compatibility.
@occivink
Copy link
Contributor Author

occivink commented Jun 6, 2022

ping

@musicfunfan
Copy link

So if i understand correctly this PR will let users like me to have a video with alpha channel display properly.
What i mean is. I have video of mine that has transparent elements. My expectation from mpv-player is to play them with transparency. For example when i have a transparent element on the video i want to see what ever is behind the player. I want the mpv window to be transparent when the video is transparent. Only on the places that the video is transparent.

Now i can not do that on my system.
Os archlinux with X11 and picom.

If this PR can do that. I would like that very much.

If a way to do that already exist please let me know.

Sorry if this comment is not relevant i just searching for a way solve my problem and i find this PR.

@occivink
Copy link
Contributor Author

What you're trying to achieve should already be possible, all you have to do is pass --alpha=yes.
This PR is only relevant if you don't want the window to be fully transparent, but instead blended with the mpv background (as specified by --background).

Regarding, this PR, I've noticed that it does not work with vo=gpu-next. Based on my understanding of the code, something in libplacebo would have to be changed. I had a look into it, but was not able to get it to work.

@musicfunfan
Copy link

When i try to do the --alpha=yes thing the transparent stuff just turn to black.... Not transparent. :(

@occivink
Copy link
Contributor Author

Ah yes, it could be that on X11 + mesa this doesn't work, see also the comments in #9862. Can you try on a wayland compositor? Anyway this is not really on-topic for this PR, maybe ask on IRC or create a new issue.

@Dudemanguy
Copy link
Member

Superseded by #13493.

@Dudemanguy Dudemanguy closed this Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alpha blending with background and transparent window
5 participants