obs-transitions: Nonlinear SRGB, fade to color

Switch back for now. Maybe we want CIELUV, but that's expensive.
master
jpark37 2021-04-21 20:37:00 -07:00
parent 00fdec2493
commit 6124a373f6
2 changed files with 6 additions and 11 deletions

View File

@ -24,7 +24,8 @@ VertData VSDefault(VertData v_in)
float4 PSFadeToColor(VertData v_in) : TARGET
{
return lerp(tex.Sample(textureSampler, v_in.uv), color, swp);
float4 premultiplied = float4(color.rgb * color.a, color.a);
return lerp(tex.Sample(textureSampler, v_in.uv), premultiplied, swp);
}
technique FadeToColor

View File

@ -52,7 +52,7 @@ static void fade_to_color_update(void *data, obs_data_t *settings)
color |= 0xFF000000;
vec4_from_rgba_srgb_premultiply(&fade_to_color->color, color);
vec4_from_rgba(&fade_to_color->color, color);
fade_to_color->switch_point = (float)swp / 100.0f;
}
@ -105,19 +105,13 @@ static void fade_to_color_callback(void *data, gs_texture_t *a, gs_texture_t *b,
float swp = t < fade_to_color->switch_point ? sa : 1.0f - sb;
gs_texture_t *const tex = (t < fade_to_color->switch_point) ? a : b;
const bool previous = gs_framebuffer_srgb_enabled();
gs_enable_framebuffer_srgb(true);
gs_effect_set_texture_srgb(fade_to_color->ep_tex, tex);
gs_effect_set_vec4(fade_to_color->ep_color, &fade_to_color->color);
gs_effect_set_texture(fade_to_color->ep_tex,
t < fade_to_color->switch_point ? a : b);
gs_effect_set_float(fade_to_color->ep_swp, swp);
gs_effect_set_vec4(fade_to_color->ep_color, &fade_to_color->color);
while (gs_effect_loop(fade_to_color->effect, "FadeToColor"))
gs_draw_sprite(NULL, 0, cx, cy);
gs_enable_framebuffer_srgb(previous);
}
static void fade_to_color_video_render(void *data, gs_effect_t *effect)