mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-14 07:45:06 +00:00
source-mirror: 'Point' rescale should use point sampling
This commit is contained in:
parent
102e4e5eeb
commit
0565065c2b
2 changed files with 26 additions and 12 deletions
|
@ -206,6 +206,7 @@ Source::Mirror::Mirror(obs_data_t* data, obs_source_t* src) {
|
||||||
m_width = m_height = 1;
|
m_width = m_height = 1;
|
||||||
m_renderTarget = std::make_unique<GS::RenderTarget>(GS_RGBA, GS_ZS_NONE);
|
m_renderTarget = std::make_unique<GS::RenderTarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
m_renderTargetScale = std::make_unique<GS::RenderTarget>(GS_RGBA, GS_ZS_NONE);
|
m_renderTargetScale = std::make_unique<GS::RenderTarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
|
m_sampler = std::make_shared<GS::Sampler>();
|
||||||
m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT);
|
m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT);
|
||||||
|
|
||||||
update(data);
|
update(data);
|
||||||
|
@ -270,21 +271,26 @@ void Source::Mirror::update(obs_data_t* data) {
|
||||||
|
|
||||||
ScalingMethod scaler = (ScalingMethod)obs_data_get_int(data, P_SCALING_METHOD);
|
ScalingMethod scaler = (ScalingMethod)obs_data_get_int(data, P_SCALING_METHOD);
|
||||||
switch (scaler) {
|
switch (scaler) {
|
||||||
case ScalingMethod::Bilinear:
|
|
||||||
m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT);
|
|
||||||
break;
|
|
||||||
case ScalingMethod::BilinearLowRes:
|
|
||||||
m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_BILINEAR_LOWRES);
|
|
||||||
break;
|
|
||||||
case ScalingMethod::Bicubic:
|
|
||||||
m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_BICUBIC);
|
|
||||||
break;
|
|
||||||
case ScalingMethod::Lanczos:
|
|
||||||
m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_LANCZOS);
|
|
||||||
break;
|
|
||||||
case ScalingMethod::Point:
|
case ScalingMethod::Point:
|
||||||
default:
|
default:
|
||||||
m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT);
|
m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT);
|
||||||
|
m_sampler->SetSampleFilter(GS_FILTER_POINT);
|
||||||
|
break;
|
||||||
|
case ScalingMethod::Bilinear:
|
||||||
|
m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT);
|
||||||
|
m_sampler->SetSampleFilter(GS_FILTER_LINEAR);
|
||||||
|
break;
|
||||||
|
case ScalingMethod::BilinearLowRes:
|
||||||
|
m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_BILINEAR_LOWRES);
|
||||||
|
m_sampler->SetSampleFilter(GS_FILTER_LINEAR);
|
||||||
|
break;
|
||||||
|
case ScalingMethod::Bicubic:
|
||||||
|
m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_BICUBIC);
|
||||||
|
m_sampler->SetSampleFilter(GS_FILTER_LINEAR);
|
||||||
|
break;
|
||||||
|
case ScalingMethod::Lanczos:
|
||||||
|
m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_LANCZOS);
|
||||||
|
m_sampler->SetSampleFilter(GS_FILTER_LINEAR);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,14 +348,20 @@ void Source::Mirror::video_render(gs_effect_t* effect) {
|
||||||
gs_ortho(0, m_width, 0, m_height, 0, 1);
|
gs_ortho(0, m_width, 0, m_height, 0, 1);
|
||||||
gs_clear(GS_CLEAR_COLOR, &black, 0, 0);
|
gs_clear(GS_CLEAR_COLOR, &black, 0, 0);
|
||||||
while (gs_effect_loop(m_scalingEffect, "Draw")) {
|
while (gs_effect_loop(m_scalingEffect, "Draw")) {
|
||||||
|
gs_eparam_t* image = gs_effect_get_param_by_name(m_scalingEffect, "image");
|
||||||
|
gs_effect_set_next_sampler(image, m_sampler->GetObject());
|
||||||
obs_source_draw(m_renderTarget->GetTextureObject(), 0, 0, m_width, m_height, false);
|
obs_source_draw(m_renderTarget->GetTextureObject(), 0, 0, m_width, m_height, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (gs_effect_loop(obs_get_base_effect(OBS_EFFECT_DEFAULT), "Draw")) {
|
while (gs_effect_loop(obs_get_base_effect(OBS_EFFECT_DEFAULT), "Draw")) {
|
||||||
|
gs_eparam_t* image = gs_effect_get_param_by_name(obs_get_base_effect(OBS_EFFECT_DEFAULT), "image");
|
||||||
|
gs_effect_set_next_sampler(image, m_sampler->GetObject());
|
||||||
obs_source_draw(m_renderTargetScale->GetTextureObject(), 0, 0, sw, sh, false);
|
obs_source_draw(m_renderTargetScale->GetTextureObject(), 0, 0, sw, sh, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (gs_effect_loop(m_scalingEffect, "Draw")) {
|
while (gs_effect_loop(m_scalingEffect, "Draw")) {
|
||||||
|
gs_eparam_t* image = gs_effect_get_param_by_name(m_scalingEffect, "image");
|
||||||
|
gs_effect_set_next_sampler(image, m_sampler->GetObject());
|
||||||
obs_source_draw(m_renderTarget->GetTextureObject(), 0, 0, m_width, m_height, false);
|
obs_source_draw(m_renderTarget->GetTextureObject(), 0, 0, m_width, m_height, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
#include "gs-rendertarget.h"
|
#include "gs-rendertarget.h"
|
||||||
|
#include "gs-sampler.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace Source {
|
namespace Source {
|
||||||
|
@ -74,6 +75,7 @@ namespace Source {
|
||||||
uint32_t m_width, m_height;
|
uint32_t m_width, m_height;
|
||||||
std::unique_ptr<GS::RenderTarget> m_renderTarget;
|
std::unique_ptr<GS::RenderTarget> m_renderTarget;
|
||||||
std::unique_ptr<GS::RenderTarget> m_renderTargetScale;
|
std::unique_ptr<GS::RenderTarget> m_renderTargetScale;
|
||||||
|
std::shared_ptr<GS::Sampler> m_sampler;
|
||||||
gs_effect_t* m_scalingEffect;
|
gs_effect_t* m_scalingEffect;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue