mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-12-29 11:01:23 +00:00
gfx/shader: Support for visible and active tracking in parameters
Co-authored-by: Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
This commit is contained in:
parent
6aa3f6dbc2
commit
bba606e439
9 changed files with 54 additions and 0 deletions
|
@ -153,6 +153,16 @@ void shader_instance::video_render(gs_effect_t* effect)
|
|||
}
|
||||
}
|
||||
|
||||
void streamfx::filter::shader::shader_instance::show()
|
||||
{
|
||||
_fx->set_visible(true);
|
||||
}
|
||||
|
||||
void streamfx::filter::shader::shader_instance::hide()
|
||||
{
|
||||
_fx->set_visible(false);
|
||||
}
|
||||
|
||||
void streamfx::filter::shader::shader_instance::activate()
|
||||
{
|
||||
_fx->set_active(true);
|
||||
|
@ -170,6 +180,7 @@ shader_factory::shader_factory()
|
|||
_info.output_flags = OBS_SOURCE_VIDEO;
|
||||
|
||||
set_activity_tracking_enabled(true);
|
||||
set_visibility_tracking_enabled(true);
|
||||
finish_setup();
|
||||
register_proxy("obs-stream-effects-filter-shader");
|
||||
}
|
||||
|
|
|
@ -44,6 +44,9 @@ namespace streamfx::filter::shader {
|
|||
virtual void video_tick(float_t sec_since_last) override;
|
||||
virtual void video_render(gs_effect_t* effect) override;
|
||||
|
||||
void show() override;
|
||||
void hide() override;
|
||||
|
||||
void activate() override;
|
||||
void deactivate() override;
|
||||
};
|
||||
|
|
|
@ -176,6 +176,10 @@ void streamfx::gfx::shader::parameter::update(obs_data_t* settings) {}
|
|||
|
||||
void streamfx::gfx::shader::parameter::assign() {}
|
||||
|
||||
void streamfx::gfx::shader::parameter::visible(bool visible) {}
|
||||
|
||||
void streamfx::gfx::shader::parameter::active(bool active) {}
|
||||
|
||||
std::shared_ptr<streamfx::gfx::shader::parameter>
|
||||
streamfx::gfx::shader::parameter::make_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix)
|
||||
{
|
||||
|
|
|
@ -80,6 +80,10 @@ namespace streamfx::gfx {
|
|||
|
||||
virtual void assign();
|
||||
|
||||
virtual void visible(bool visible);
|
||||
|
||||
virtual void active(bool enabled);
|
||||
|
||||
public:
|
||||
inline streamfx::obs::gs::effect_parameter get_parameter()
|
||||
{
|
||||
|
|
|
@ -592,10 +592,23 @@ void streamfx::gfx::shader::shader::set_transition_size(uint32_t w, uint32_t h)
|
|||
}
|
||||
}
|
||||
|
||||
void streamfx::gfx::shader::shader::set_visible(bool visible)
|
||||
{
|
||||
_visible = visible;
|
||||
|
||||
for (auto kv : _shader_params) {
|
||||
kv.second->visible(visible);
|
||||
}
|
||||
}
|
||||
|
||||
void streamfx::gfx::shader::shader::set_active(bool active)
|
||||
{
|
||||
_active = active;
|
||||
|
||||
for (auto kv : _shader_params) {
|
||||
kv.second->active(active);
|
||||
}
|
||||
|
||||
// Recreate Per-Activation-Random values.
|
||||
for (size_t idx = 0; idx < 4; idx++) {
|
||||
_random_values[4 + idx] =
|
||||
|
|
|
@ -48,6 +48,7 @@ namespace streamfx::gfx {
|
|||
uint32_t _base_width;
|
||||
uint32_t _base_height;
|
||||
bool _active;
|
||||
bool _visible;
|
||||
|
||||
// Shader
|
||||
streamfx::obs::gs::effect _shader;
|
||||
|
@ -125,6 +126,8 @@ namespace streamfx::gfx {
|
|||
|
||||
void set_transition_size(uint32_t w, uint32_t h);
|
||||
|
||||
void set_visible(bool visible);
|
||||
|
||||
void set_active(bool active);
|
||||
};
|
||||
} // namespace shader
|
||||
|
|
|
@ -106,6 +106,16 @@ void shader_instance::video_render(gs_effect_t* effect)
|
|||
_fx->render(effect);
|
||||
}
|
||||
|
||||
void streamfx::source::shader::shader_instance::show()
|
||||
{
|
||||
_fx->set_visible(true);
|
||||
}
|
||||
|
||||
void streamfx::source::shader::shader_instance::hide()
|
||||
{
|
||||
_fx->set_visible(false);
|
||||
}
|
||||
|
||||
void streamfx::source::shader::shader_instance::activate()
|
||||
{
|
||||
_fx->set_active(true);
|
||||
|
@ -123,6 +133,7 @@ shader_factory::shader_factory()
|
|||
_info.output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW;
|
||||
|
||||
set_activity_tracking_enabled(true);
|
||||
set_visibility_tracking_enabled(true);
|
||||
finish_setup();
|
||||
register_proxy("obs-stream-effects-source-shader");
|
||||
}
|
||||
|
|
|
@ -43,6 +43,9 @@ namespace streamfx::source::shader {
|
|||
virtual void video_tick(float_t sec_since_last) override;
|
||||
virtual void video_render(gs_effect_t* effect) override;
|
||||
|
||||
void show() override;
|
||||
void hide() override;
|
||||
|
||||
void activate() override;
|
||||
void deactivate() override;
|
||||
};
|
||||
|
|
|
@ -129,12 +129,14 @@ bool shader_instance::audio_render(uint64_t* ts_out, obs_source_audio_mix* audio
|
|||
|
||||
void shader_instance::transition_start()
|
||||
{
|
||||
_fx->set_visible(true);
|
||||
_fx->set_active(true);
|
||||
}
|
||||
|
||||
void shader_instance::transition_stop()
|
||||
{
|
||||
_fx->set_active(false);
|
||||
_fx->set_visible(false);
|
||||
}
|
||||
|
||||
shader_factory::shader_factory()
|
||||
|
|
Loading…
Reference in a new issue