obs-transitions: Add 'Luma Wipe' transition
Closes jp9000/obs-studio#558
@ -7,6 +7,7 @@ set(obs-transitions_SOURCES
|
||||
transition-fade.c
|
||||
transition-cut.c
|
||||
transition-fade-to-color.c
|
||||
transition-luma-wipe.c
|
||||
)
|
||||
|
||||
add_library(obs-transitions MODULE
|
||||
|
@ -11,3 +11,41 @@ Direction.Down="Down"
|
||||
SwipeIn="Swipe In"
|
||||
Color="Color"
|
||||
SwitchPoint="Peak Color Point (percentage)"
|
||||
LumaWipeTransition="Luma Wipe"
|
||||
LumaWipe.Image="Image"
|
||||
LumaWipe.Invert="Invert"
|
||||
LumaWipe.Softness="Softness"
|
||||
LumaWipe.Type.BarndoorBottomLeft="Barndoor Bottom Left"
|
||||
LumaWipe.Type.BarndoorHorizontal="Barndoor Horizontal"
|
||||
LumaWipe.Type.BarndoorTopLeft="Barndoor Top Left"
|
||||
LumaWipe.Type.BarndoorVertical="Barndoor Vertical"
|
||||
LumaWipe.Type.BlindsHorizontal="Blinds Horizontal"
|
||||
LumaWipe.Type.BoxBottomLeft="Box Bottom Left"
|
||||
LumaWipe.Type.BoxBottomRight="Box Bottom Right"
|
||||
LumaWipe.Type.BoxTopLeft="Box Top Left"
|
||||
LumaWipe.Type.BoxTopRight="Box Top Right"
|
||||
LumaWipe.Type.Burst="Burst"
|
||||
LumaWipe.Type.CheckerboardSmall="Checkerboard Small"
|
||||
LumaWipe.Type.Circles="Circles"
|
||||
LumaWipe.Type.Clock="Clock"
|
||||
LumaWipe.Type.Cloud="Cloud"
|
||||
LumaWipe.Type.Curtain="Curtain"
|
||||
LumaWipe.Type.Fan="Fan"
|
||||
LumaWipe.Type.Fractal="Fractal"
|
||||
LumaWipe.Type.Iris="Iris"
|
||||
LumaWipe.Type.LinearHorizontal="Linear Horizontal"
|
||||
LumaWipe.Type.LinearTopLeft="Linear Top Left"
|
||||
LumaWipe.Type.LinearTopRight="Linear Top Right"
|
||||
LumaWipe.Type.LinearVertical="Linear Vertical"
|
||||
LumaWipe.Type.ParallelZigzagHorizontal="Parallel Zigzag Horizontal"
|
||||
LumaWipe.Type.ParallelZigzagVertical="Parallel Zigzag Vertical"
|
||||
LumaWipe.Type.Sinus9="Sinus 9"
|
||||
LumaWipe.Type.Spiral="Spiral"
|
||||
LumaWipe.Type.Square="Square"
|
||||
LumaWipe.Type.Squares="Squares"
|
||||
LumaWipe.Type.Stripes="Stripes"
|
||||
LumaWipe.Type.StripsHorizontal="Strips Horizontal"
|
||||
LumaWipe.Type.StripsVertical="Strips Vertical"
|
||||
LumaWipe.Type.Watercolor="Watercolor"
|
||||
LumaWipe.Type.ZigzagHorizontal="Zigzag Horizontal"
|
||||
LumaWipe.Type.ZigzagVertical="Zigzag Vertical"
|
||||
|
61
plugins/obs-transitions/data/luma_wipe_transition.effect
Normal file
@ -0,0 +1,61 @@
|
||||
// Based rendermix wipe shader
|
||||
// https://github.com/rectalogic/rendermix-basic-effects/blob/master/assets/com/rendermix/Wipe/Wipe.frag
|
||||
|
||||
uniform float4x4 ViewProj;
|
||||
uniform texture2d a_tex;
|
||||
uniform texture2d b_tex;
|
||||
uniform texture2d l_tex;
|
||||
uniform float progress;
|
||||
uniform bool invert;
|
||||
uniform float softness;
|
||||
|
||||
sampler_state textureSampler {
|
||||
Filter = Linear;
|
||||
AddressU = Clamp;
|
||||
AddressV = Clamp;
|
||||
};
|
||||
|
||||
struct VertData {
|
||||
float4 pos : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertData VSDefault(VertData v_in)
|
||||
{
|
||||
VertData vert_out;
|
||||
vert_out.pos = mul(float4(v_in.pos.xyz, 1.0), ViewProj);
|
||||
vert_out.uv = v_in.uv;
|
||||
return vert_out;
|
||||
}
|
||||
|
||||
float4 PSLumaWipe(VertData v_in) : TARGET
|
||||
{
|
||||
float2 uv = v_in.uv;
|
||||
float4 a_color = a_tex.Sample(textureSampler, uv);
|
||||
float4 b_color = b_tex.Sample(textureSampler, uv);
|
||||
float luma = l_tex.Sample(textureSampler, uv).x;
|
||||
|
||||
if (invert)
|
||||
luma = 1.0f - luma;
|
||||
|
||||
float time = lerp(0.0f, 1.0f + softness, progress);
|
||||
|
||||
if (luma <= time - softness)
|
||||
return b_color;
|
||||
|
||||
if (luma >= time)
|
||||
return a_color;
|
||||
|
||||
float alpha = (time - luma) / softness;
|
||||
|
||||
return lerp(a_color, b_color, alpha);
|
||||
}
|
||||
|
||||
technique LumaWipe
|
||||
{
|
||||
pass
|
||||
{
|
||||
vertex_shader = VSDefault(v_in);
|
||||
pixel_shader = PSLumaWipe(v_in);
|
||||
}
|
||||
}
|
BIN
plugins/obs-transitions/data/luma_wipes/barndoor-botleft.png
Normal file
After Width: | Height: | Size: 61 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/barndoor-h.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/barndoor-topleft.png
Normal file
After Width: | Height: | Size: 62 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/barndoor-v.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/blinds-h.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/box-botleft.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/box-botright.png
Normal file
After Width: | Height: | Size: 6.5 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/box-topleft.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/box-topright.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/burst.png
Normal file
After Width: | Height: | Size: 107 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/checkerboard-small.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/circles.png
Normal file
After Width: | Height: | Size: 107 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/clock.png
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/cloud.png
Normal file
After Width: | Height: | Size: 287 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/curtain.png
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/fan.png
Normal file
After Width: | Height: | Size: 45 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/fractal.png
Normal file
After Width: | Height: | Size: 129 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/iris.png
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/linear-h.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/linear-topleft.png
Normal file
After Width: | Height: | Size: 59 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/linear-topright.png
Normal file
After Width: | Height: | Size: 60 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/linear-v.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/parallel-zigzag-h.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/parallel-zigzag-v.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/sinus9.png
Normal file
After Width: | Height: | Size: 54 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/spiral.png
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/square.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/squares.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/stripes.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/strips-h.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/strips-v.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/watercolor.png
Normal file
After Width: | Height: | Size: 77 KiB |
36
plugins/obs-transitions/data/luma_wipes/wipes.json
Normal file
@ -0,0 +1,36 @@
|
||||
{
|
||||
"LumaWipe.Type.BarndoorBottomLeft": "barndoor-botleft.png",
|
||||
"LumaWipe.Type.BarndoorHorizontal": "barndoor-h.png",
|
||||
"LumaWipe.Type.BarndoorTopLeft": "barndoor-topleft.png",
|
||||
"LumaWipe.Type.BarndoorVertical": "barndoor-v.png",
|
||||
"LumaWipe.Type.BlindsHorizontal": "blinds-h.png",
|
||||
"LumaWipe.Type.BoxBottomLeft": "box-botleft.png",
|
||||
"LumaWipe.Type.BoxBottomRight": "box-botright.png",
|
||||
"LumaWipe.Type.BoxTopLeft": "box-topleft.png",
|
||||
"LumaWipe.Type.BoxTopRight": "box-topright.png",
|
||||
"LumaWipe.Type.Burst": "burst.png",
|
||||
"LumaWipe.Type.CheckerboardSmall": "checkerboard-small.png",
|
||||
"LumaWipe.Type.Circles": "circles.png",
|
||||
"LumaWipe.Type.Clock": "clock.png",
|
||||
"LumaWipe.Type.Cloud": "cloud.png",
|
||||
"LumaWipe.Type.Curtain": "curtain.png",
|
||||
"LumaWipe.Type.Fan": "fan.png",
|
||||
"LumaWipe.Type.Fractal": "fractal.png",
|
||||
"LumaWipe.Type.Iris": "iris.png",
|
||||
"LumaWipe.Type.LinearHorizontal": "linear-h.png",
|
||||
"LumaWipe.Type.LinearTopLeft": "linear-topleft.png",
|
||||
"LumaWipe.Type.LinearTopRight": "linear-topright.png",
|
||||
"LumaWipe.Type.LinearVertical": "linear-v.png",
|
||||
"LumaWipe.Type.ParallelZigzagHorizontal": "parallel-zigzag-h.png",
|
||||
"LumaWipe.Type.ParallelZigzagVertical": "parallel-zigzag-v.png",
|
||||
"LumaWipe.Type.Sinus9": "sinus9.png",
|
||||
"LumaWipe.Type.Spiral": "spiral.png",
|
||||
"LumaWipe.Type.Square": "square.png",
|
||||
"LumaWipe.Type.Squares": "squares.png",
|
||||
"LumaWipe.Type.Stripes": "stripes.png",
|
||||
"LumaWipe.Type.StripsHorizontal": "strips-h.png",
|
||||
"LumaWipe.Type.StripsVertical": "strips-v.png",
|
||||
"LumaWipe.Type.Watercolor": "watercolor.png",
|
||||
"LumaWipe.Type.ZigzagHorizontal": "zigzag-h.png",
|
||||
"LumaWipe.Type.ZigzagVertical": "zigzag-v.png"
|
||||
}
|
BIN
plugins/obs-transitions/data/luma_wipes/zigzag-h.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
plugins/obs-transitions/data/luma_wipes/zigzag-v.png
Normal file
After Width: | Height: | Size: 18 KiB |
@ -9,6 +9,7 @@ extern struct obs_source_info fade_transition;
|
||||
extern struct obs_source_info swipe_transition;
|
||||
extern struct obs_source_info slide_transition;
|
||||
extern struct obs_source_info fade_to_color_transition;
|
||||
extern struct obs_source_info luma_wipe_transition;
|
||||
|
||||
bool obs_module_load(void)
|
||||
{
|
||||
@ -17,5 +18,6 @@ bool obs_module_load(void)
|
||||
obs_register_source(&swipe_transition);
|
||||
obs_register_source(&slide_transition);
|
||||
obs_register_source(&fade_to_color_transition);
|
||||
obs_register_source(&luma_wipe_transition);
|
||||
return true;
|
||||
}
|
||||
|
213
plugins/obs-transitions/transition-luma-wipe.c
Normal file
@ -0,0 +1,213 @@
|
||||
#include <obs-module.h>
|
||||
#include <graphics/image-file.h>
|
||||
#include <util/dstr.h>
|
||||
|
||||
#define S_LUMA_IMG "luma_image"
|
||||
#define S_LUMA_INV "luma_invert"
|
||||
#define S_LUMA_SOFT "luma_softness"
|
||||
|
||||
#define T_LUMA_IMG obs_module_text("LumaWipe.Image")
|
||||
#define T_LUMA_INV obs_module_text("LumaWipe.Invert")
|
||||
#define T_LUMA_SOFT obs_module_text("LumaWipe.Softness")
|
||||
|
||||
struct luma_wipe_info {
|
||||
obs_source_t *source;
|
||||
|
||||
gs_effect_t *effect;
|
||||
gs_eparam_t *ep_a_tex;
|
||||
gs_eparam_t *ep_b_tex;
|
||||
gs_eparam_t *ep_l_tex;
|
||||
gs_eparam_t *ep_progress;
|
||||
gs_eparam_t *ep_invert;
|
||||
gs_eparam_t *ep_softness;
|
||||
|
||||
gs_image_file_t luma_image;
|
||||
bool invert_luma;
|
||||
float softness;
|
||||
obs_data_t *wipes_list;
|
||||
};
|
||||
|
||||
static const char *luma_wipe_get_name(void *type_data)
|
||||
{
|
||||
UNUSED_PARAMETER(type_data);
|
||||
return obs_module_text("LumaWipeTransition");
|
||||
}
|
||||
|
||||
static void luma_wipe_update(void *data, obs_data_t *settings)
|
||||
{
|
||||
struct luma_wipe_info *lwipe = data;
|
||||
|
||||
const char *name = obs_data_get_string(settings, S_LUMA_IMG);
|
||||
lwipe->invert_luma = obs_data_get_bool(settings, S_LUMA_INV);
|
||||
lwipe->softness = (float)obs_data_get_double(settings, S_LUMA_SOFT);
|
||||
|
||||
struct dstr path = {0};
|
||||
|
||||
dstr_copy(&path, "luma_wipes/");
|
||||
dstr_cat(&path, name);
|
||||
|
||||
char *file = obs_module_file(path.array);
|
||||
|
||||
obs_enter_graphics();
|
||||
gs_image_file_free(&lwipe->luma_image);
|
||||
obs_leave_graphics();
|
||||
|
||||
gs_image_file_init(&lwipe->luma_image, file);
|
||||
|
||||
obs_enter_graphics();
|
||||
gs_image_file_init_texture(&lwipe->luma_image);
|
||||
obs_leave_graphics();
|
||||
|
||||
bfree(file);
|
||||
dstr_free(&path);
|
||||
|
||||
UNUSED_PARAMETER(settings);
|
||||
}
|
||||
|
||||
static void luma_wipe_get_list(void *data)
|
||||
{
|
||||
struct luma_wipe_info *lwipe = data;
|
||||
|
||||
char *path = obs_module_file("luma_wipes/wipes.json");
|
||||
|
||||
lwipe->wipes_list = obs_data_create_from_json_file(path);
|
||||
|
||||
bfree(path);
|
||||
}
|
||||
|
||||
static void *luma_wipe_create(obs_data_t *settings, obs_source_t *source)
|
||||
{
|
||||
struct luma_wipe_info *lwipe;
|
||||
gs_effect_t *effect;
|
||||
char *file = obs_module_file("luma_wipe_transition.effect");
|
||||
|
||||
obs_enter_graphics();
|
||||
effect = gs_effect_create_from_file(file, NULL);
|
||||
obs_leave_graphics();
|
||||
|
||||
if (!effect) {
|
||||
blog(LOG_ERROR, "Could not open luma_wipe_transition.effect");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bfree(file);
|
||||
|
||||
lwipe = bzalloc(sizeof(*lwipe));
|
||||
|
||||
lwipe->effect = effect;
|
||||
lwipe->ep_a_tex = gs_effect_get_param_by_name(effect, "a_tex");
|
||||
lwipe->ep_b_tex = gs_effect_get_param_by_name(effect, "b_tex");
|
||||
lwipe->ep_l_tex = gs_effect_get_param_by_name(effect, "l_tex");
|
||||
lwipe->ep_progress = gs_effect_get_param_by_name(effect, "progress");
|
||||
lwipe->ep_invert = gs_effect_get_param_by_name(effect, "invert");
|
||||
lwipe->ep_softness = gs_effect_get_param_by_name(effect, "softness");
|
||||
lwipe->source = source;
|
||||
|
||||
luma_wipe_get_list(lwipe);
|
||||
|
||||
luma_wipe_update(lwipe, settings);
|
||||
|
||||
return lwipe;
|
||||
}
|
||||
|
||||
static void luma_wipe_destroy(void *data)
|
||||
{
|
||||
struct luma_wipe_info *lwipe = data;
|
||||
|
||||
obs_enter_graphics();
|
||||
gs_image_file_free(&lwipe->luma_image);
|
||||
obs_leave_graphics();
|
||||
|
||||
obs_data_release(lwipe->wipes_list);
|
||||
|
||||
bfree(lwipe);
|
||||
}
|
||||
|
||||
static obs_properties_t *luma_wipe_properties(void *data)
|
||||
{
|
||||
obs_properties_t *props = obs_properties_create();
|
||||
struct luma_wipe_info *lwipe = data;
|
||||
|
||||
obs_property_t *p;
|
||||
|
||||
p = obs_properties_add_list(props, S_LUMA_IMG, T_LUMA_IMG,
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
|
||||
|
||||
obs_data_item_t *item = obs_data_first(lwipe->wipes_list);
|
||||
|
||||
for (; item != NULL; obs_data_item_next(&item)) {
|
||||
const char *name = obs_data_item_get_name(item);
|
||||
const char *path = obs_data_item_get_string(item);
|
||||
obs_property_list_add_string(p, obs_module_text(name), path);
|
||||
}
|
||||
|
||||
obs_properties_add_float(props, S_LUMA_SOFT, T_LUMA_SOFT, 0.0, 1.0, 0.05);
|
||||
obs_properties_add_bool(props, S_LUMA_INV, T_LUMA_INV);
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
static void luma_wipe_defaults(obs_data_t *settings)
|
||||
{
|
||||
obs_data_set_default_string(settings, S_LUMA_IMG, "linear-h.png");
|
||||
obs_data_set_default_double(settings, S_LUMA_SOFT, 0.03);
|
||||
obs_data_set_default_bool(settings, S_LUMA_INV, false);
|
||||
}
|
||||
|
||||
static void luma_wipe_callback(void *data, gs_texture_t *a, gs_texture_t *b,
|
||||
float t, uint32_t cx, uint32_t cy)
|
||||
{
|
||||
struct luma_wipe_info *lwipe = data;
|
||||
|
||||
gs_effect_set_texture(lwipe->ep_a_tex, a);
|
||||
gs_effect_set_texture(lwipe->ep_b_tex, b);
|
||||
gs_effect_set_texture(lwipe->ep_l_tex, lwipe->luma_image.texture);
|
||||
gs_effect_set_float(lwipe->ep_progress, t);
|
||||
|
||||
gs_effect_set_bool(lwipe->ep_invert, lwipe->invert_luma);
|
||||
gs_effect_set_float(lwipe->ep_softness, lwipe->softness);
|
||||
|
||||
while (gs_effect_loop(lwipe->effect, "LumaWipe"))
|
||||
gs_draw_sprite(NULL, 0, cx, cy);
|
||||
}
|
||||
|
||||
void luma_wipe_video_render(void *data, gs_effect_t *effect)
|
||||
{
|
||||
struct luma_wipe_info *lwipe = data;
|
||||
obs_transition_video_render(lwipe->source, luma_wipe_callback);
|
||||
UNUSED_PARAMETER(effect);
|
||||
}
|
||||
|
||||
static float mix_a(void *data, float t)
|
||||
{
|
||||
UNUSED_PARAMETER(data);
|
||||
return 1.0f - t;
|
||||
}
|
||||
|
||||
static float mix_b(void *data, float t)
|
||||
{
|
||||
UNUSED_PARAMETER(data);
|
||||
return t;
|
||||
}
|
||||
|
||||
bool luma_wipe_audio_render(void *data, uint64_t *ts_out,
|
||||
struct obs_source_audio_mix *audio, uint32_t mixers,
|
||||
size_t channels, size_t sample_rate)
|
||||
{
|
||||
struct luma_wipe_info *lwipe = data;
|
||||
return obs_transition_audio_render(lwipe->source, ts_out, audio, mixers,
|
||||
channels, sample_rate, mix_a, mix_b);
|
||||
}
|
||||
|
||||
struct obs_source_info luma_wipe_transition = {
|
||||
.id = "wipe_transition",
|
||||
.type = OBS_SOURCE_TYPE_TRANSITION,
|
||||
.get_name = luma_wipe_get_name,
|
||||
.create = luma_wipe_create,
|
||||
.destroy = luma_wipe_destroy,
|
||||
.update = luma_wipe_update,
|
||||
.video_render = luma_wipe_video_render,
|
||||
.audio_render = luma_wipe_audio_render,
|
||||
.get_properties = luma_wipe_properties,
|
||||
.get_defaults = luma_wipe_defaults
|
||||
};
|