Make capture sources w/o alpha use opaque effect
This fixes an issue primarily with filter rendering: when capturing windows and displays, their alpha channel is almost always 0, causing the image to be completely invisible unintentionally. The original fix for this for many sources was just to turn off the blending, which would be fine if you're not rendering any filters, but filters will render to render targets first, and that lack of alpha will end up carrying over in to the final image. This doesn't apply to any mac captures because mac actually seems to set the alpha channel to 1.
This commit is contained in:
@@ -501,6 +501,7 @@ void XCompcapMain::tick(float seconds)
|
||||
void XCompcapMain::render(gs_effect_t *effect)
|
||||
{
|
||||
PLock lock(&p->lock, true);
|
||||
effect = obs_get_opaque_effect();
|
||||
|
||||
if (!lock.isLocked() || !p->tex)
|
||||
return;
|
||||
@@ -508,13 +509,17 @@ void XCompcapMain::render(gs_effect_t *effect)
|
||||
gs_eparam_t *image = gs_effect_get_param_by_name(effect, "image");
|
||||
gs_effect_set_texture(image, p->tex);
|
||||
|
||||
gs_enable_blending(false);
|
||||
gs_draw_sprite(p->tex, 0, 0, 0);
|
||||
while (gs_effect_loop(effect, "Draw")) {
|
||||
gs_draw_sprite(p->tex, 0, 0, 0);
|
||||
}
|
||||
|
||||
if (p->cursor && p->gltex && p->show_cursor && !p->cursor_outside)
|
||||
xcursor_render(p->cursor);
|
||||
if (p->cursor && p->gltex && p->show_cursor && !p->cursor_outside) {
|
||||
effect = obs_get_default_effect();
|
||||
|
||||
gs_reset_blend_state();
|
||||
while (gs_effect_loop(effect, "Draw")) {
|
||||
xcursor_render(p->cursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t XCompcapMain::width()
|
||||
|
@@ -96,14 +96,17 @@ void xcb_xcursor_render(xcb_xcursor_t *data)
|
||||
gs_eparam_t *image = gs_effect_get_param_by_name(effect, "image");
|
||||
gs_effect_set_texture(image, data->tex);
|
||||
|
||||
gs_blend_state_push();
|
||||
gs_blend_function(GS_BLEND_SRCALPHA, GS_BLEND_INVSRCALPHA);
|
||||
gs_enable_color(true, true, true, false);
|
||||
|
||||
gs_matrix_push();
|
||||
gs_matrix_translate3f(data->x_render, data->y_render, 0.0f);
|
||||
|
||||
gs_enable_blending(true);
|
||||
gs_blend_function(GS_BLEND_ONE, GS_BLEND_INVSRCALPHA);
|
||||
gs_draw_sprite(data->tex, 0, 0, 0);
|
||||
|
||||
gs_matrix_pop();
|
||||
|
||||
gs_enable_color(true, true, true, true);
|
||||
gs_blend_state_pop();
|
||||
}
|
||||
|
||||
void xcb_xcursor_offset(xcb_xcursor_t* data, const int x_org, const int y_org)
|
||||
|
@@ -106,14 +106,17 @@ void xcursor_render(xcursor_t *data) {
|
||||
gs_eparam_t *image = gs_effect_get_param_by_name(effect, "image");
|
||||
gs_effect_set_texture(image, data->tex);
|
||||
|
||||
gs_blend_state_push();
|
||||
gs_blend_function(GS_BLEND_SRCALPHA, GS_BLEND_INVSRCALPHA);
|
||||
gs_enable_color(true, true, true, false);
|
||||
|
||||
gs_matrix_push();
|
||||
gs_matrix_translate3f(data->render_x, data->render_y, 0.0f);
|
||||
|
||||
gs_enable_blending(True);
|
||||
gs_blend_function(GS_BLEND_ONE, GS_BLEND_INVSRCALPHA);
|
||||
gs_draw_sprite(data->tex, 0, 0, 0);
|
||||
|
||||
gs_matrix_pop();
|
||||
|
||||
gs_enable_color(true, true, true, true);
|
||||
gs_blend_state_pop();
|
||||
}
|
||||
|
||||
void xcursor_offset(xcursor_t* data, int_fast32_t x_org, int_fast32_t y_org)
|
||||
|
@@ -431,19 +431,25 @@ static void xshm_video_render(void *vptr, gs_effect_t *effect)
|
||||
{
|
||||
XSHM_DATA(vptr);
|
||||
|
||||
effect = obs_get_opaque_effect();
|
||||
|
||||
if (!data->texture)
|
||||
return;
|
||||
|
||||
gs_eparam_t *image = gs_effect_get_param_by_name(effect, "image");
|
||||
gs_effect_set_texture(image, data->texture);
|
||||
|
||||
gs_enable_blending(false);
|
||||
gs_draw_sprite(data->texture, 0, 0, 0);
|
||||
while (gs_effect_loop(effect, "Draw")) {
|
||||
gs_draw_sprite(data->texture, 0, 0, 0);
|
||||
}
|
||||
|
||||
if (data->show_cursor)
|
||||
xcb_xcursor_render(data->cursor);
|
||||
if (data->show_cursor) {
|
||||
effect = obs_get_default_effect();
|
||||
|
||||
gs_reset_blend_state();
|
||||
while (gs_effect_loop(effect, "Draw")) {
|
||||
xcb_xcursor_render(data->cursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user