diff --git a/source/gfx/shader/gfx-shader-param-basic.cpp b/source/gfx/shader/gfx-shader-param-basic.cpp index 6352f33e..4bec8d54 100644 --- a/source/gfx/shader/gfx-shader-param-basic.cpp +++ b/source/gfx/shader/gfx-shader-param-basic.cpp @@ -190,6 +190,9 @@ void gfx::shader::bool_parameter::defaults(obs_data_t* settings) void gfx::shader::bool_parameter::properties(obs_properties_t* props, obs_data_t* settings) { + if (!is_visible()) + return; + // TODO: Support for bool[] if (get_size() == 1) { auto p = obs_properties_add_list(props, get_key().c_str(), get_name().c_str(), OBS_COMBO_TYPE_LIST, @@ -203,6 +206,9 @@ void gfx::shader::bool_parameter::properties(obs_properties_t* props, obs_data_t void gfx::shader::bool_parameter::update(obs_data_t* settings) { + if (is_automatic()) + return; + // TODO: Support for bool[] if (get_size() == 1) { _data[0] = static_cast(obs_data_get_int(settings, get_key().c_str())); @@ -286,6 +292,9 @@ static inline obs_property_t* build_float_property(gfx::shader::basic_field_type void gfx::shader::float_parameter::properties(obs_properties_t* props, obs_data_t* settings) { + if (!is_visible()) + return; + auto grp = obs_properties_create(); if (get_size() == 1) { auto p = build_float_property(_field_type, props, _keys[0].c_str(), _names[0].c_str(), _min[0].f32, _max[0].f32, @@ -316,6 +325,9 @@ void gfx::shader::float_parameter::update(obs_data_t* settings) void gfx::shader::float_parameter::assign() { + if (is_automatic()) + return; + get_parameter().set_value(_data.data(), get_size()); } diff --git a/source/gfx/shader/gfx-shader-param.cpp b/source/gfx/shader/gfx-shader-param.cpp index 5bf6cc5c..4e610887 100644 --- a/source/gfx/shader/gfx-shader-param.cpp +++ b/source/gfx/shader/gfx-shader-param.cpp @@ -22,6 +22,7 @@ #define ANNO_ORDER "order" #define ANNO_VISIBILITY "visible" +#define ANNO_AUTOMATIC "automatic" #define ANNO_NAME "name" #define ANNO_DESCRIPTION "description" #define ANNO_TYPE "type" @@ -118,6 +119,14 @@ gfx::shader::parameter::parameter(gs::effect_parameter param, std::string key_pr _name = (_key); } + // Read Order + if (auto anno = _param.get_annotation(ANNO_VISIBILITY); anno) { + _visible = anno.get_default_bool(); + } + if (auto anno = _param.get_annotation(ANNO_AUTOMATIC); anno) { + _automatic = anno.get_default_bool(); + } + // Read Order if (auto anno = _param.get_annotation(ANNO_ORDER); anno) { _order = anno.get_default_int(); @@ -196,6 +205,11 @@ bool gfx::shader::parameter::is_visible() return true; } +bool gfx::shader::parameter::is_automatic() +{ + return _automatic; +} + bool gfx::shader::parameter::has_name() { return _name.length() > 0; diff --git a/source/gfx/shader/gfx-shader-param.hpp b/source/gfx/shader/gfx-shader-param.hpp index 3718b3aa..70c7fc04 100644 --- a/source/gfx/shader/gfx-shader-param.hpp +++ b/source/gfx/shader/gfx-shader-param.hpp @@ -75,6 +75,7 @@ namespace gfx { // Visibility, name and description. bool _visible; + bool _automatic; std::string _name; std::string _description; @@ -104,6 +105,8 @@ namespace gfx { bool is_visible(); + bool is_automatic(); + bool has_name(); const std::string& get_name(); diff --git a/source/gfx/shader/gfx-shader.cpp b/source/gfx/shader/gfx-shader.cpp index c100a3c7..3f42c326 100644 --- a/source/gfx/shader/gfx-shader.cpp +++ b/source/gfx/shader/gfx-shader.cpp @@ -243,8 +243,7 @@ bool gfx::shader::shader::on_properties_modified(obs_properties_t* props, obs_pr // Rebuild new parameters. for (auto kv : _shader_params) { - if (kv.second->is_visible()) - kv.second->properties(grp, data); + kv.second->properties(grp, data); kv.second->defaults(data); kv.second->update(data); }