mirror of
https://github.com/mpv-player/mpv
synced 2025-01-30 19:52:14 +00:00
vo_opengl: blend transparent video against tiles by default
Add a "blend-tiles" choice to the "alpha" sub-option. This is pretty simplistic and uses the GL raster position to derive the tiles. A weird consequence is that using --vo=opengl and --vo=opengl-hq gives different scaling behavior (screenspace pixel size vs. source video pixel size 16x16 tiles), but it seems we don't have easy access to the original texture coordinates. Using the rasterpos is probably simpler. Make this option the default.
This commit is contained in:
parent
3de6c9aa42
commit
eac0665b8d
@ -957,9 +957,11 @@ Available video output drivers are:
|
|||||||
things like softsubbed ASS signs to match the video colors,
|
things like softsubbed ASS signs to match the video colors,
|
||||||
but may cause SRT subtitles or similar to look slightly off.
|
but may cause SRT subtitles or similar to look slightly off.
|
||||||
|
|
||||||
``alpha=<blend|yes|no>``
|
``alpha=<blend-tiles|blend|yes|no>``
|
||||||
Decides what to do if the input has an alpha component (default: blend).
|
Decides what to do if the input has an alpha component.
|
||||||
|
|
||||||
|
blend-tiles
|
||||||
|
Blend the frame against a 16x16 gray/white tiles background (default).
|
||||||
blend
|
blend
|
||||||
Blend the frame against a black background.
|
Blend the frame against a black background.
|
||||||
yes
|
yes
|
||||||
|
@ -345,7 +345,7 @@ const struct gl_video_opts gl_video_opts_def = {
|
|||||||
.clamp = 1, }, // tscale
|
.clamp = 1, }, // tscale
|
||||||
},
|
},
|
||||||
.scaler_lut_size = 6,
|
.scaler_lut_size = 6,
|
||||||
.alpha_mode = 2,
|
.alpha_mode = 3,
|
||||||
.background = {0, 0, 0, 255},
|
.background = {0, 0, 0, 255},
|
||||||
.gamma = 1.0f,
|
.gamma = 1.0f,
|
||||||
.prescale_passes = 1,
|
.prescale_passes = 1,
|
||||||
@ -369,7 +369,7 @@ const struct gl_video_opts gl_video_opts_hq_def = {
|
|||||||
.clamp = 1, }, // tscale
|
.clamp = 1, }, // tscale
|
||||||
},
|
},
|
||||||
.scaler_lut_size = 6,
|
.scaler_lut_size = 6,
|
||||||
.alpha_mode = 2,
|
.alpha_mode = 3,
|
||||||
.background = {0, 0, 0, 255},
|
.background = {0, 0, 0, 255},
|
||||||
.gamma = 1.0f,
|
.gamma = 1.0f,
|
||||||
.blend_subs = 0,
|
.blend_subs = 0,
|
||||||
@ -441,7 +441,8 @@ const struct m_sub_options gl_video_conf = {
|
|||||||
OPT_CHOICE("alpha", alpha_mode, 0,
|
OPT_CHOICE("alpha", alpha_mode, 0,
|
||||||
({"no", 0},
|
({"no", 0},
|
||||||
{"yes", 1},
|
{"yes", 1},
|
||||||
{"blend", 2})),
|
{"blend", 2},
|
||||||
|
{"blend-tiles", 3})),
|
||||||
OPT_FLAG("rectangle-textures", use_rectangle, 0),
|
OPT_FLAG("rectangle-textures", use_rectangle, 0),
|
||||||
OPT_COLOR("background", background, 0),
|
OPT_COLOR("background", background, 0),
|
||||||
OPT_FLAG("interpolation", interpolation, 0),
|
OPT_FLAG("interpolation", interpolation, 0),
|
||||||
@ -1532,8 +1533,12 @@ static void pass_convert_yuv(struct gl_video *p)
|
|||||||
|
|
||||||
if (!p->has_alpha || p->opts.alpha_mode == 0) { // none
|
if (!p->has_alpha || p->opts.alpha_mode == 0) { // none
|
||||||
GLSL(color.a = 1.0;)
|
GLSL(color.a = 1.0;)
|
||||||
} else if (p->opts.alpha_mode == 2) { // blend
|
} else if (p->opts.alpha_mode == 2) { // blend against black
|
||||||
GLSL(color = vec4(color.rgb * color.a, 1.0);)
|
GLSL(color = vec4(color.rgb * color.a, 1.0);)
|
||||||
|
} else if (p->opts.alpha_mode == 3) { // blend against tiles
|
||||||
|
GLSL(bvec2 tile = lessThan(fract(gl_FragCoord.xy / 32.0), vec2(0.5));)
|
||||||
|
GLSL(vec3 background = vec3(mix(0.75, 1.0, tile.x != tile.y));)
|
||||||
|
GLSL(color.rgb = color.rgb * color.a + background * (1.0 - color.a);)
|
||||||
} else if (p->gl->fb_premultiplied) {
|
} else if (p->gl->fb_premultiplied) {
|
||||||
GLSL(color = vec4(color.rgb * color.a, color.a);)
|
GLSL(color = vec4(color.rgb * color.a, color.a);)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user