mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-09 17:29:59 +01:00
Refactor ImageFilter to remove channel1_output_session and update blending logic in shaders
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
// Blending of source texture (channel 0) with output window loopback (channel 1)
|
// Blending of source texture (channel 0) with texture of an external Source
|
||||||
// by Bruno Herbelin for vimix
|
// by Bruno Herbelin for vimix
|
||||||
uniform float Blend;
|
uniform float Blend;
|
||||||
|
uniform sampler2D Source;
|
||||||
|
|
||||||
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
{
|
{
|
||||||
vec2 uv = fragCoord.xy / iResolution.xy;
|
vec2 uv = fragCoord.xy / iResolution.xy;
|
||||||
fragColor = mix( texture(iChannel0, uv), texture(iChannel1, uv), Blend);
|
fragColor = mix( texture(iChannel0, uv), texture(Source, uv), Blend);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ void ImageFilteringShader::copy(ImageFilteringShader const& S)
|
|||||||
/// ////
|
/// ////
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
|
|
||||||
ImageFilter::ImageFilter (): FrameBufferFilter(), buffers_({nullptr, nullptr}), channel1_output_session(true)
|
ImageFilter::ImageFilter (): FrameBufferFilter(), buffers_({nullptr, nullptr})
|
||||||
{
|
{
|
||||||
// surface and shader for first pass
|
// surface and shader for first pass
|
||||||
shaders_.first = new ImageFilteringShader;
|
shaders_.first = new ImageFilteringShader;
|
||||||
@@ -459,8 +459,6 @@ void ImageFilter::draw (FrameBuffer *input)
|
|||||||
if ( enabled() || forced )
|
if ( enabled() || forced )
|
||||||
{
|
{
|
||||||
// FIRST PASS
|
// FIRST PASS
|
||||||
if (channel1_output_session)
|
|
||||||
shaders_.first->secondary_texture = Mixer::manager().session()->frame()->texture();
|
|
||||||
|
|
||||||
// loop over sampler2D uniforms to bind textures
|
// loop over sampler2D uniforms to bind textures
|
||||||
uint texture_unit = 0;
|
uint texture_unit = 0;
|
||||||
@@ -480,8 +478,6 @@ void ImageFilter::draw (FrameBuffer *input)
|
|||||||
|
|
||||||
// SECOND PASS
|
// SECOND PASS
|
||||||
if ( program_.isTwoPass() ) {
|
if ( program_.isTwoPass() ) {
|
||||||
if (channel1_output_session)
|
|
||||||
shaders_.second->secondary_texture = Mixer::manager().session()->frame()->texture();
|
|
||||||
// render filtered surface from first pass into frame buffer
|
// render filtered surface from first pass into frame buffer
|
||||||
buffers_.second->begin();
|
buffers_.second->begin();
|
||||||
surfaces_.second->draw(glm::identity<glm::mat4>(), buffers_.second->projection());
|
surfaces_.second->draw(glm::identity<glm::mat4>(), buffers_.second->projection());
|
||||||
@@ -703,7 +699,7 @@ std::vector< FilteringProgram > ResampleFilter::programs_ = {
|
|||||||
|
|
||||||
ResampleFilter::ResampleFilter (): ImageFilter(), factor_(RESAMPLE_INVALID)
|
ResampleFilter::ResampleFilter (): ImageFilter(), factor_(RESAMPLE_INVALID)
|
||||||
{
|
{
|
||||||
channel1_output_session = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResampleFilter::setFactor(int factor)
|
void ResampleFilter::setFactor(int factor)
|
||||||
@@ -841,7 +837,6 @@ std::vector< FilteringProgram > BlurFilter::programs_ = {
|
|||||||
BlurFilter::BlurFilter (): ImageFilter(), method_(BLUR_INVALID), mipmap_buffer_(nullptr)
|
BlurFilter::BlurFilter (): ImageFilter(), method_(BLUR_INVALID), mipmap_buffer_(nullptr)
|
||||||
{
|
{
|
||||||
mipmap_surface_ = new Surface;
|
mipmap_surface_ = new Surface;
|
||||||
channel1_output_session = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BlurFilter::~BlurFilter ()
|
BlurFilter::~BlurFilter ()
|
||||||
@@ -983,7 +978,7 @@ std::vector< FilteringProgram > SharpenFilter::programs_ = {
|
|||||||
|
|
||||||
SharpenFilter::SharpenFilter (): ImageFilter(), method_(SHARPEN_INVALID)
|
SharpenFilter::SharpenFilter (): ImageFilter(), method_(SHARPEN_INVALID)
|
||||||
{
|
{
|
||||||
channel1_output_session = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharpenFilter::setMethod(int method)
|
void SharpenFilter::setMethod(int method)
|
||||||
@@ -1061,7 +1056,7 @@ std::vector< FilteringProgram > SmoothFilter::programs_ = {
|
|||||||
|
|
||||||
SmoothFilter::SmoothFilter (): ImageFilter(), method_(SMOOTH_INVALID)
|
SmoothFilter::SmoothFilter (): ImageFilter(), method_(SMOOTH_INVALID)
|
||||||
{
|
{
|
||||||
channel1_output_session = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmoothFilter::setMethod(int method)
|
void SmoothFilter::setMethod(int method)
|
||||||
@@ -1132,7 +1127,7 @@ std::vector< FilteringProgram > EdgeFilter::programs_ = {
|
|||||||
|
|
||||||
EdgeFilter::EdgeFilter (): ImageFilter(), method_(EDGE_INVALID)
|
EdgeFilter::EdgeFilter (): ImageFilter(), method_(EDGE_INVALID)
|
||||||
{
|
{
|
||||||
channel1_output_session = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EdgeFilter::setMethod(int method)
|
void EdgeFilter::setMethod(int method)
|
||||||
@@ -1203,7 +1198,7 @@ std::vector< FilteringProgram > AlphaFilter::programs_ = {
|
|||||||
|
|
||||||
AlphaFilter::AlphaFilter (): ImageFilter(), operation_(ALPHA_INVALID)
|
AlphaFilter::AlphaFilter (): ImageFilter(), operation_(ALPHA_INVALID)
|
||||||
{
|
{
|
||||||
channel1_output_session = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlphaFilter::setOperation(int op)
|
void AlphaFilter::setOperation(int op)
|
||||||
|
|||||||
@@ -169,7 +169,6 @@ protected:
|
|||||||
std::pair< FrameBuffer *, FrameBuffer * > buffers_;
|
std::pair< FrameBuffer *, FrameBuffer * > buffers_;
|
||||||
std::pair< ImageFilteringShader *, ImageFilteringShader *> shaders_;
|
std::pair< ImageFilteringShader *, ImageFilteringShader *> shaders_;
|
||||||
void updateParameters();
|
void updateParameters();
|
||||||
bool channel1_output_session;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user