mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-10 22:05:06 +00:00
effects: Add Draw, DrawPremultiplied to 'standard.effect'
This commit is contained in:
parent
744d627bc5
commit
948976fce1
2 changed files with 54 additions and 10 deletions
|
@ -1,18 +1,62 @@
|
||||||
#include "shared.effect"
|
#include "shared.effect"
|
||||||
|
|
||||||
uniform texture2D Channel0;
|
uniform texture2D InputA<
|
||||||
uniform texture2D Channel1;
|
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
|
// Technique: Restore Alpha
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// - Channel0: RGBX Texture
|
// - InputA: RGBX Texture
|
||||||
// - Channel1: XXXA Texture
|
// - InputB: XXXA Texture
|
||||||
|
|
||||||
float4 PSRestoreAlpha(VertexData vtx) : TARGET {
|
float4 PSRestoreAlpha(VertexData vtx) : TARGET {
|
||||||
float4 rgbx = Channel0.Sample(BlankSampler, vtx.uv);
|
float4 rgbx = InputA.Sample(BlankSampler, vtx.uv);
|
||||||
float4 xxxa = Channel1.Sample(BlankSampler, vtx.uv);
|
float4 xxxa = InputB.Sample(BlankSampler, vtx.uv);
|
||||||
rgbx.a = xxxa.a;
|
rgbx.a = xxxa.a;
|
||||||
return rgbx;
|
return rgbx;
|
||||||
};
|
};
|
||||||
|
|
|
@ -337,11 +337,11 @@ void denoising_instance::video_render(gs_effect_t* effect)
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
::streamfx::obs::gs::debug_marker profiler1{::streamfx::obs::gs::debug_color_render, "Render"};
|
::streamfx::obs::gs::debug_marker profiler1{::streamfx::obs::gs::debug_color_render, "Render"};
|
||||||
#endif
|
#endif
|
||||||
if (_standard_effect->has_parameter("Channel0", ::streamfx::obs::gs::effect_parameter::type::Texture)) {
|
if (_standard_effect->has_parameter("InputA", ::streamfx::obs::gs::effect_parameter::type::Texture)) {
|
||||||
_standard_effect->get_parameter("Channel0").set_texture(_output);
|
_standard_effect->get_parameter("InputA").set_texture(_output);
|
||||||
}
|
}
|
||||||
if (_standard_effect->has_parameter("Channel1", ::streamfx::obs::gs::effect_parameter::type::Texture)) {
|
if (_standard_effect->has_parameter("InputB", ::streamfx::obs::gs::effect_parameter::type::Texture)) {
|
||||||
_standard_effect->get_parameter("Channel1").set_texture(_input->get_texture());
|
_standard_effect->get_parameter("InputB").set_texture(_input->get_texture());
|
||||||
}
|
}
|
||||||
while (gs_effect_loop(_standard_effect->get_object(), "RestoreAlpha")) {
|
while (gs_effect_loop(_standard_effect->get_object(), "RestoreAlpha")) {
|
||||||
gs_draw_sprite(nullptr, 0, _size.first, _size.second);
|
gs_draw_sprite(nullptr, 0, _size.first, _size.second);
|
||||||
|
|
Loading…
Reference in a new issue