+
+-- TODO: Deal with inputs that are different from our native 1280x720 resolution.
+
+local transition_start = -2.0
+local transition_end = -1.0
+local zoom_src = 0.0
+local zoom_dst = 1.0
+local zoom_poi = 0 -- which input to zoom in on
+local fade_src_signal = 0
+local fade_dst_signal = 0
+
+local input0_neutral_color = {0.5, 0.5, 0.5}
+local input1_neutral_color = {0.5, 0.5, 0.5}
+
+local live_signal_num = 0
+local preview_signal_num = 1
+
+-- Valid values for live_signal_num and preview_signal_num.
+local INPUT0_SIGNAL_NUM = 0
+local INPUT1_SIGNAL_NUM = 1
+local SBS_SIGNAL_NUM = 2
+local STATIC_SIGNAL_NUM = 3
+
+-- “fake” signal numbers that signifies that we are fading from one input
+-- to the next.
+local FADE_VTV_SIGNAL_NUM = 4 -- Video to/from video.
+local FADE_VTP_SIGNAL_NUM = 5 -- Video to/from static picture.
+
+-- The main live chain.
+function make_sbs_chain(hq)
+ local chain = EffectChain.new(16, 9)
+ local input0 = chain:add_live_input(true)
+ input0:connect_signal(0)
+ local input0_wb_effect = chain:add_effect(WhiteBalanceEffect.new())
+ local input1 = chain:add_live_input(true)
+ input1:connect_signal(1)
+ local input1_wb_effect = chain:add_effect(WhiteBalanceEffect.new())
+
+ local resample_effect = nil
+ local resize_effect = nil
+ if (hq) then
+ resample_effect = chain:add_effect(ResampleEffect.new(), input0_wb_effect)
+ else
+ resize_effect = chain:add_effect(ResizeEffect.new(), input0_wb_effect)
+ end
+
+ local padding_effect = chain:add_effect(IntegralPaddingEffect.new())
+ padding_effect:set_vec4("border_color", 0.0, 0.0, 0.0, 1.0)
+
+ local resample2_effect = nil
+ local resize2_effect = nil
+ if (hq) then
+ resample2_effect = chain:add_effect(ResampleEffect.new(), input1_wb_effect)
+ else
+ resize2_effect = chain:add_effect(ResizeEffect.new(), input1_wb_effect)
+ end
+ local padding2_effect = chain:add_effect(IntegralPaddingEffect.new())
+
+ chain:add_effect(OverlayEffect.new(), padding_effect, padding2_effect)
+ chain:finalize(hq)
+
+ return {
+ chain = chain,
+ input0 = {
+ input = input0,
+ white_balance_effect = input0_wb_effect,
+ resample_effect = resample_effect,
+ resize_effect = resize_effect,
+ padding_effect = padding_effect
+ },
+ input1 = {
+ input = input1,
+ white_balance_effect = input1_wb_effect,
+ resample_effect = resample2_effect,
+ resize_effect = resize2_effect,
+ padding_effect = padding2_effect
+ }
+ }
+end
+
+local main_chain_hq = make_sbs_chain(true)
+local main_chain_lq = make_sbs_chain(false)
+
+-- A chain to fade between two inputs (live chain only)
+local fade_vtv_chain_hq = EffectChain.new(16, 9)
+local fade_vtv_chain_hq_input0 = fade_vtv_chain_hq:add_live_input(true)
+local fade_vtv_chain_hq_wb0_effect = fade_vtv_chain_hq:add_effect(WhiteBalanceEffect.new())
+local fade_vtv_chain_hq_input1 = fade_vtv_chain_hq:add_live_input(true)
+local fade_vtv_chain_hq_wb1_effect = fade_vtv_chain_hq:add_effect(WhiteBalanceEffect.new())
+fade_vtv_chain_hq_input0:connect_signal(0)
+fade_vtv_chain_hq_input1:connect_signal(1)
+local fade_vtv_chain_mix_effect = fade_vtv_chain_hq:add_effect(MixEffect.new(), fade_vtv_chain_hq_wb0_effect, fade_vtv_chain_hq_wb1_effect)
+fade_vtv_chain_hq:finalize(true)
+
+-- A chain to fade between an inputs and a picture (live chain only)
+local fade_vtp_chain_hq = EffectChain.new(16, 9)
+local fade_vtp_chain_hq_input0 = fade_vtp_chain_hq:add_live_input(true)
+local fade_vtp_chain_hq_wb0_effect = fade_vtp_chain_hq:add_effect(WhiteBalanceEffect.new())
+local fade_vtp_chain_hq_input1 = fade_vtp_chain_hq:add_effect(ImageInput.new("bg.jpeg"))
+fade_vtp_chain_hq_input0:connect_signal(0)
+local fade_vtp_chain_mix_effect = fade_vtp_chain_hq:add_effect(MixEffect.new(), fade_vtp_chain_hq_wb0_effect, fade_vtp_chain_hq_input1)
+fade_vtp_chain_hq:finalize(true)
+
+-- A chain to show a single input on screen (HQ version).
+local simple_chain_hq = EffectChain.new(16, 9)
+local simple_chain_hq_input = simple_chain_hq:add_live_input(true)
+simple_chain_hq_input:connect_signal(0) -- First input card. Can be changed whenever you want.
+local simple_chain_hq_wb_effect = simple_chain_hq:add_effect(WhiteBalanceEffect.new())
+simple_chain_hq:finalize(true)
+
+-- A chain to show a single input on screen (LQ version).
+local simple_chain_lq = EffectChain.new(16, 9)
+local simple_chain_lq_input = simple_chain_lq:add_live_input(true)
+simple_chain_lq_input:connect_signal(0) -- First input card. Can be changed whenever you want.
+local simple_chain_lq_wb_effect = simple_chain_lq:add_effect(WhiteBalanceEffect.new())
+simple_chain_lq:finalize(false)
+
+-- A chain to show a single static picture on screen (HQ version).
+local static_chain_hq = EffectChain.new(16, 9)
+local static_chain_hq_input = static_chain_hq:add_effect(ImageInput.new("bg.jpeg"))
+static_chain_hq:finalize(true)
+
+-- A chain to show a single static picture on screen (LQ version).
+local static_chain_lq = EffectChain.new(16, 9)
+local static_chain_lq_input = static_chain_lq:add_effect(ImageInput.new("bg.jpeg"))
+static_chain_lq:finalize(false)