diff --git a/data/effects/standard.effect b/data/effects/standard.effect index a6ad5050..873bb6ea 100644 --- a/data/effects/standard.effect +++ b/data/effects/standard.effect @@ -1,18 +1,62 @@ #include "shared.effect" -uniform texture2D Channel0; -uniform texture2D Channel1; +uniform texture2D InputA< + bool automatic = true; +>; +uniform texture2D InputB< + bool automatic = true; +>; + +//------------------------------------------------------------------------------ +// Technique: Draw +//------------------------------------------------------------------------------ +// Parameters: +// - InputA: RGBA Texture + +float4 PSDraw(VertexData vtx) : TARGET { + return InputA.Sample(BlankSampler, vtx.uv); +}; + +technique Draw +{ + pass + { + vertex_shader = DefaultVertexShader(vtx); + pixel_shader = PSDraw(vtx); + }; +}; + +//------------------------------------------------------------------------------ +// Technique: Draw +//------------------------------------------------------------------------------ +// Parameters: +// - InputA: RGBA Texture + +float4 PSDrawPremultiplied(VertexData vtx) : TARGET { + float4 rgba = InputA.Sample(BlankSampler, vtx.uv); + rgba.rgb /= rgba.a > (1. / 1024.) ? rgba.a : 1.0; + return rgba; +}; + +technique DrawPremultiplied +{ + pass + { + vertex_shader = DefaultVertexShader(vtx); + pixel_shader = PSDrawPremultiplied(vtx); + }; +}; //------------------------------------------------------------------------------ // Technique: Restore Alpha //------------------------------------------------------------------------------ // Parameters: -// - Channel0: RGBX Texture -// - Channel1: XXXA Texture +// - InputA: RGBX Texture +// - InputB: XXXA Texture float4 PSRestoreAlpha(VertexData vtx) : TARGET { - float4 rgbx = Channel0.Sample(BlankSampler, vtx.uv); - float4 xxxa = Channel1.Sample(BlankSampler, vtx.uv); + float4 rgbx = InputA.Sample(BlankSampler, vtx.uv); + float4 xxxa = InputB.Sample(BlankSampler, vtx.uv); rgbx.a = xxxa.a; return rgbx; }; diff --git a/source/filters/filter-denoising.cpp b/source/filters/filter-denoising.cpp index 156ed350..8844dd8a 100644 --- a/source/filters/filter-denoising.cpp +++ b/source/filters/filter-denoising.cpp @@ -337,11 +337,11 @@ void denoising_instance::video_render(gs_effect_t* effect) #ifdef ENABLE_PROFILING ::streamfx::obs::gs::debug_marker profiler1{::streamfx::obs::gs::debug_color_render, "Render"}; #endif - if (_standard_effect->has_parameter("Channel0", ::streamfx::obs::gs::effect_parameter::type::Texture)) { - _standard_effect->get_parameter("Channel0").set_texture(_output); + if (_standard_effect->has_parameter("InputA", ::streamfx::obs::gs::effect_parameter::type::Texture)) { + _standard_effect->get_parameter("InputA").set_texture(_output); } - if (_standard_effect->has_parameter("Channel1", ::streamfx::obs::gs::effect_parameter::type::Texture)) { - _standard_effect->get_parameter("Channel1").set_texture(_input->get_texture()); + if (_standard_effect->has_parameter("InputB", ::streamfx::obs::gs::effect_parameter::type::Texture)) { + _standard_effect->get_parameter("InputB").set_texture(_input->get_texture()); } while (gs_effect_loop(_standard_effect->get_object(), "RestoreAlpha")) { gs_draw_sprite(nullptr, 0, _size.first, _size.second);