-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature request] follow with filter target scaling changes #2
Comments
Hey yuni, thanks for the kind words. I ran into a fair amount of issues with sizing when I was originally working on this filter. Unfortunately, as best as I could determine (and best as I can remember at this moment, there was a fair amount of information I was unable to access at the stage in rendering that the filter applies. I recall being unable to determine the size of the eventual render target (which would be needed in order to calculate how much to scale in your example there.) This is the same thing that stopped me from working on trying to get "pixel perfect" outputs to work nicely as well. If there's something I've missed and someone with more OBS knowledge wanted to take a whack at it, I'd be wildly appreciative; I just don't see a path forward as it currently stands. |
Thank you. I have also checked libobs code and get same conclusion 😢 The points are followings:
In this case, it is desired to implement rendering mode on libobs side. Especially, extend |
ah... wait, just I have an idea for getting maybe we can use (Anyway, if we use this way, we cannot put same(duplicated) source onto two scenes...) |
maybe, we can obtain the scene info from following code (But I'm not sure because I cannot build this plugin on my environment...) struct cb_data {
obs_source_t *parent;
obs_sceneitem_t *found;
};
typedef struct cb_data cb_data_t;
static bool enum_scenes_callback(void *data_ptr, obs_source_t *scene_source)
{
cb_data_t *data = data_ptr;
obs_source_t *scene = obs_group_or_scene_from_source(scene_source);
if (!scene)
return true;
obs_sceneitem_t *found = obs_scene_find_source_recursive(
scene, obs_source_get_name(data->parent));
if (!found)
return true;
// found the scene-item that contain our source!
data->found = found;
return false;
}
static void filter_render(void *data, gs_effect_t *effect)
{
UNUSED_PARAMETER(effect);
struct filter_9slice *context = data;
if (!context) {
return;
}
obs_source_t *parent = obs_filter_get_parent(context->source);
struct cb_data target = {
.parent = parent,
.found = NULL,
};
obs_enum_scenes(enum_scenes_callback, &target);
struct vec2 scale = {.x = 1.0f, .y = 1.0f};
if (target.found) {
scale = target.found->scale;
}
const float width = obs_source_get_width(parent) * scale.x;
const float height = obs_source_get_height(parent) * scale.y;
context->last_source_size.x = (float)width;
context->last_source_size.y = (float)height;
const struct vec2 output_size = {
.x = width * context->output_pixel_scale.x,
.y = height * context->output_pixel_scale.y};
if (!obs_source_process_filter_begin(context->source, GS_RGBA,
OBS_ALLOW_DIRECT_RENDERING))
return;
struct filter_9slice_params_t *params = &context->params;
gs_effect_set_vec4(params->border, &context->border);
gs_effect_set_vec2(params->source_size, &context->last_source_size);
gs_effect_set_vec2(params->output_size, &output_size);
gs_effect_set_bool(params->show_uvs, context->show_uvs);
gs_effect_set_bool(params->use_linear_filtering,
context->use_linear_filtering);
obs_source_process_filter_end(context->source, context->effect, width,
height);
} how do you think about it...? @nitz |
bugfix: too strong slice restriction for first open
I'll close this issue because the feature is now implemented. Thank you review and advice about it 👍 |
Hiya. Thank you for creating good obs filter! 👍
But unfortunately, this filter seems not follow parent(or target) source or scene's transform changes. Currently, if filter target was scaled, this filter's output image is just scaled with normal algorithms.
If this is implemented, user can use image as like a "component" and very smooth to use it.
(i.e. users can manage the "component" size with just scaling on OBS UI.)
So I want to request the feature to follow parent source transform.
The text was updated successfully, but these errors were encountered: