From f8b14bdb462bfa56dfc129908f48df4c2e4ec297 Mon Sep 17 00:00:00 2001 From: Michael Fabian Dirks Date: Mon, 17 Jul 2017 12:45:20 +0200 Subject: [PATCH] libobs: Ensure scene items don't have pre-multiplied alpha Scene items would incorrectly have pre-multiplied alpha when they were scaled with different scale filtering, when they were cropped, or when the item itself was a scene. This happens because the scene renders the items to a texture in those cases, and when they are rendered to a texture the blend function would be the default srcalpha/invsrcalpha blend function, which would cause alpha to become pre-multiplied in the texture's result rather than straight alpha. This changes the behavior to directly copy the color/alpha to the texture using the one/zero blend function instead, which makes the resulting texture straight alpha. (Note that you do not want to turn off the blend mode for the same result because certain sources can have custom drawing that may rely on blending being available) Related Issue: https://obsproject.com/mantis/view.php?id=954 Closes jp9000/obs-studio#966 --- libobs/obs-scene.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libobs/obs-scene.c b/libobs/obs-scene.c index dc6b4d858..969dc90b3 100644 --- a/libobs/obs-scene.c +++ b/libobs/obs-scene.c @@ -486,7 +486,10 @@ static inline void render_item(struct obs_scene_item *item) -(float)item->crop.top, 0.0f); + gs_blend_state_push(); + gs_blend_function(GS_BLEND_ONE, GS_BLEND_ZERO); obs_source_video_render(item->source); + gs_blend_state_pop(); gs_texrender_end(item->item_render); } }