mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-12-28 18:41:14 +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"
|
||||
|
||||
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;
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue