diff --git a/data/locale/en-US.ini b/data/locale/en-US.ini index a092aa28..d912413c 100644 --- a/data/locale/en-US.ini +++ b/data/locale/en-US.ini @@ -1,8 +1,27 @@ +# Generic +Advanced="Advanced" + +# Filter - Blur +Filter.Blur="Blur" +Filter.Blur.Type="Type" +Filter.Blur.Type.Description="The type of blur to apply:\n- 'Box' smoothes pixels equally.\n- 'Gaussian' applies a gaussian curve to the smoothed pixels.\n- 'Bilateral' is an edge detection variant of 'Gaussian'." +Filter.Blur.Type.Box="Box" +Filter.Blur.Type.Gaussian="Gaussian" +Filter.Blur.Type.Bilateral="Bilateral" +Filter.Blur.Size="Size (Pixel)" +Filter.Blur.Size.Description="Area size of the blur, large sizes may cause:\n- Skipped frames\n- Frame loss or drops\n- Input lag\n- GPU overheating\n- or other issues." +Filter.Blur.Bilateral.Smoothing="Smoothing" +Filter.Blur.Bilateral.Sharpness="Sharpness" +Filter.Blur.ColorFormat="Color Format" + +# Filter - Displacement Filter.Displacement="Displacement Mapping" Filter.Displacement.File="File" Filter.Displacement.File.Types="Images (*.png *.jpeg *.jpg *.bmp *.tga);;All Files (*)" Filter.Displacement.Ratio="Ratio" Filter.Displacement.Scale="Scale" + +# Filter - Shape Filter.Shape="Shape" Filter.Shape.Loop="Repeat last Point" Filter.Shape.Points="Points" @@ -10,6 +29,8 @@ Filter.Shape.Point.X="Point %llu X" Filter.Shape.Point.Y="Point %llu Y" Filter.Shape.Point.U="Point %llu U" Filter.Shape.Point.V="Point %llu V" + +# Filter - Transform Filter.Transform="3D Transform" Filter.Transform.Camera="Camera" Filter.Transform.Camera.Description="Projection mode used by the camera." @@ -43,27 +64,23 @@ Filter.Transform.Rotation.Description="Euler rotation of the rendered quad, appl Filter.Transform.Rotation.X="Pitch (X)" Filter.Transform.Rotation.Y="Yaw (Y)" Filter.Transform.Rotation.Z="Roll (Z)" -Filter.Blur="Blur" -Filter.Blur.Type="Type" -Filter.Blur.Type.Description="The type of blur to apply:\n- 'Box' smoothes pixels equally.\n- 'Gaussian' applies a gaussian curve to the smoothed pixels.\n- 'Bilateral' is an edge detection variant of 'Gaussian'." -Filter.Blur.Type.Box="Box" -Filter.Blur.Type.Gaussian="Gaussian" -Filter.Blur.Type.Bilateral="Bilateral" -Filter.Blur.Size="Size (Pixel)" -Filter.Blur.Size.Description="Area size of the blur, large sizes may cause:\n- Skipped frames\n- Frame loss or drops\n- Input lag\n- GPU overheating\n- or other issues." -Filter.Blur.Bilateral.Smoothing="Smoothing" -Filter.Blur.Bilateral.Sharpness="Sharpness" -Filter.Blur.ColorFormat="Color Format" + +# Source - Mirror Source.Mirror="Source Mirror" Source.Mirror.Source="Source" +Source.Mirror.Source.Description="Which Source should be mirrored?" Source.Mirror.Source.Size="Source Size" +Source.Mirror.Source.Size.Description="The size of the source being mirrored. (Automatically updated)" Source.Mirror.Scaling="Rescale Source" +Source.Mirror.Scaling.Description="Should the source be rescaled?" Source.Mirror.Scaling.Method="Filter" +Source.Mirror.Scaling.Method.Description="Which filter should be used for rescaling?" Source.Mirror.Scaling.Method.Point="Point" Source.Mirror.Scaling.Method.Bilinear="Bilinear" Source.Mirror.Scaling.Method.BilinearLowRes="Bilinear (Low Resolution)" Source.Mirror.Scaling.Method.Bicubic="Bicubic" Source.Mirror.Scaling.Method.Lanczos="Lanczos" Source.Mirror.Scaling.Size="Size" - -Advanced="Advanced" +Source.Mirror.Scaling.Size.Description="What size should we rescale to? (WxH format)" +Source.Mirror.Scaling.TransformKeepOriginal="Use Original Size for Transforms" +Source.Mirror.Scaling.TransformKeepOriginal.Description="Should the filter not modify the size of the source?" diff --git a/source/source-mirror.cpp b/source/source-mirror.cpp index 5f908407..e5546d51 100644 --- a/source/source-mirror.cpp +++ b/source/source-mirror.cpp @@ -34,6 +34,7 @@ #define P_SCALING_METHOD_BICUBIC "Source.Mirror.Scaling.Method.Bicubic" #define P_SCALING_METHOD_LANCZOS "Source.Mirror.Scaling.Method.Lanczos" #define P_SCALING_SIZE "Source.Mirror.Scaling.Size" +#define P_SCALING_TRANSFORMKEEPORIGINAL "Source.Mirror.Scaling.TransformKeepOriginal" enum class ScalingMethod : int64_t { Point, @@ -154,6 +155,9 @@ obs_properties_t * Source::MirrorAddon::get_properties(void *ptr) { OBS_TEXT_DEFAULT); obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SCALING_SIZE))); + p = obs_properties_add_bool(pr, P_SCALING_TRANSFORMKEEPORIGINAL, P_TRANSLATE(P_SCALING_TRANSFORMKEEPORIGINAL)); + obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SCALING_TRANSFORMKEEPORIGINAL))); + return pr; } @@ -201,6 +205,7 @@ Source::Mirror::Mirror(obs_data_t* data, obs_source_t* src) { m_rescale = false; m_width = m_height = 1; m_renderTarget = std::make_unique(GS_RGBA, GS_ZS_NONE); + m_renderTargetScale = std::make_unique(GS_RGBA, GS_ZS_NONE); m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT); update(data); @@ -211,7 +216,7 @@ Source::Mirror::~Mirror() { } uint32_t Source::Mirror::get_width() { - if (m_rescale && m_width > 0) + if (m_rescale && m_width > 0 && !m_keepOriginalSize) return m_width; if (m_target && m_target != m_source) return obs_source_get_width(m_target); @@ -219,7 +224,7 @@ uint32_t Source::Mirror::get_width() { } uint32_t Source::Mirror::get_height() { - if (m_rescale && m_height > 0) + if (m_rescale && m_height > 0 && !m_keepOriginalSize) return m_height; if (m_target && m_target != m_source) return obs_source_get_height(m_target); @@ -282,6 +287,8 @@ void Source::Mirror::update(obs_data_t* data) { m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT); break; } + + m_keepOriginalSize = obs_data_get_bool(data, P_SCALING_TRANSFORMKEEPORIGINAL); } } @@ -310,27 +317,41 @@ void Source::Mirror::video_render(gs_effect_t* effect) { // Store original Source Texture try { vec4 black; vec4_zero(&black); - auto op = m_renderTarget->Render(m_width, m_height); + auto op = m_renderTarget->Render(sw, sh); gs_ortho(0, sw, 0, sh, 0, 1); gs_clear(GS_CLEAR_COLOR, &black, 0, 0); - gs_eparam_t *scale_param = gs_effect_get_param_by_name(m_scalingEffect, "base_dimension_i"); - if (scale_param) { - struct vec2 base_res_i = { - 1.0f / (float)sw, - 1.0f / (float)sh - }; - gs_effect_set_vec2(scale_param, &base_res_i); - } - while (gs_effect_loop(m_scalingEffect, "Draw")) { - obs_source_video_render(m_target); - } + obs_source_video_render(m_target); } catch (...) { return; } - while (gs_effect_loop(obs_get_base_effect(OBS_EFFECT_DEFAULT), "Draw")) { - obs_source_draw(m_renderTarget->GetTextureObject(), 0, 0, m_width, m_height, false); + gs_eparam_t *scale_param = gs_effect_get_param_by_name(m_scalingEffect, "base_dimension_i"); + if (scale_param) { + struct vec2 base_res_i = { + 1.0f / (float)sw, + 1.0f / (float)sh + }; + gs_effect_set_vec2(scale_param, &base_res_i); + } + + if (m_keepOriginalSize) { + { + vec4 black; vec4_zero(&black); + auto op = m_renderTargetScale->Render(m_width, m_height); + gs_ortho(0, m_width, 0, m_height, 0, 1); + gs_clear(GS_CLEAR_COLOR, &black, 0, 0); + while (gs_effect_loop(m_scalingEffect, "Draw")) { + 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")) { + obs_source_draw(m_renderTargetScale->GetTextureObject(), 0, 0, sw, sh, false); + } + } else { + while (gs_effect_loop(m_scalingEffect, "Draw")) { + obs_source_draw(m_renderTarget->GetTextureObject(), 0, 0, m_width, m_height, false); + } } } else { obs_source_video_render(m_target); diff --git a/source/source-mirror.h b/source/source-mirror.h index 39bd3f16..bd4e1f60 100644 --- a/source/source-mirror.h +++ b/source/source-mirror.h @@ -70,8 +70,10 @@ namespace Source { std::string m_targetName; bool m_rescale = false; + bool m_keepOriginalSize = false; uint32_t m_width, m_height; std::unique_ptr m_renderTarget; + std::unique_ptr m_renderTargetScale; gs_effect_t* m_scalingEffect; }; };