Browse Source

obs-transitions: Linear SRGB, swipe

jpark37 5 years ago
parent
commit
14d9b57422
1 changed files with 16 additions and 2 deletions
  1. 16 2
      plugins/obs-transitions/transition-swipe.c

+ 16 - 2
plugins/obs-transitions/transition-swipe.c

@@ -88,12 +88,26 @@ static void swipe_callback(void *data, gs_texture_t *a, gs_texture_t *b,
 
 	vec2_mulf(&swipe_val, &swipe_val, swipe->swipe_in ? 1.0f - t : t);
 
-	gs_effect_set_texture(swipe->a_param, swipe->swipe_in ? b : a);
-	gs_effect_set_texture(swipe->b_param, swipe->swipe_in ? a : b);
+	const bool linear_srgb = gs_get_linear_srgb();
+
+	const bool previous = gs_framebuffer_srgb_enabled();
+	gs_enable_framebuffer_srgb(linear_srgb);
+
+	gs_texture_t *t0 = swipe->swipe_in ? b : a;
+	gs_texture_t *t1 = swipe->swipe_in ? a : b;
+	if (linear_srgb) {
+		gs_effect_set_texture_srgb(swipe->a_param, t0);
+		gs_effect_set_texture_srgb(swipe->b_param, t1);
+	} else {
+		gs_effect_set_texture(swipe->a_param, t0);
+		gs_effect_set_texture(swipe->b_param, t1);
+	}
 	gs_effect_set_vec2(swipe->swipe_param, &swipe_val);
 
 	while (gs_effect_loop(swipe->effect, "Swipe"))
 		gs_draw_sprite(NULL, 0, cx, cy);
+
+	gs_enable_framebuffer_srgb(previous);
 }
 
 static void swipe_video_render(void *data, gs_effect_t *effect)