diff --git a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc index e38b846171ee..4326fc6bf008 100644 --- a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc +++ b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc @@ -4,6 +4,7 @@ #include #include "BKE_object.h" +#include "BLI_set.hh" #include "DEG_depsgraph_query.h" #include "DNA_scene_types.h" @@ -236,6 +237,9 @@ void BlenderSceneDelegate::set_setting(const std::string &key, const pxr::VtValu if (key == "MaterialXFilenameKey") { settings.mx_filename_key = pxr::TfToken(val.Get()); } + else { + settings.render_tokens.add_overwrite(pxr::TfToken(key), val); + } } pxr::SdfPath BlenderSceneDelegate::prim_id(ID *id, const char *prefix) const diff --git a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.h b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.h index 16f659d99b3e..c7b1468408e4 100644 --- a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.h +++ b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.h @@ -11,7 +11,7 @@ #include "CLG_log.h" -#include "BLI_set.hh" +#include "BLI_map.hh" #include "curves.h" #include "instancer.h" #include "light.h" @@ -34,6 +34,7 @@ class BlenderSceneDelegate : public pxr::HdSceneDelegate { public: struct Settings { pxr::TfToken mx_filename_key; + Map render_tokens; }; BlenderSceneDelegate(pxr::HdRenderIndex *parent_index, diff --git a/source/blender/render/hydra/scene_delegate/id.h b/source/blender/render/hydra/scene_delegate/id.h index c210236e2ba3..ccfba5a61584 100644 --- a/source/blender/render/hydra/scene_delegate/id.h +++ b/source/blender/render/hydra/scene_delegate/id.h @@ -17,6 +17,13 @@ template<> struct blender::DefaultHash { } }; +template<> struct blender::DefaultHash { + uint64_t operator()(const pxr::TfToken &value) const + { + return pxr::TfHash()(value); + } +}; + namespace blender::render::hydra { class BlenderSceneDelegate; diff --git a/source/blender/render/hydra/scene_delegate/light.cc b/source/blender/render/hydra/scene_delegate/light.cc index 1fe8d830fedb..b9952f2ddad2 100644 --- a/source/blender/render/hydra/scene_delegate/light.cc +++ b/source/blender/render/hydra/scene_delegate/light.cc @@ -144,17 +144,12 @@ pxr::VtValue LightData::get_data(pxr::TfToken const &key) const if (it != data_.end()) { return pxr::VtValue(it->second); } - else { - std::string n = key.GetString(); - if (boost::algorithm::contains(n, "object:visibility:")) { - if (boost::algorithm::ends_with(n, "camera") || boost::algorithm::ends_with(n, "shadow")) { - return pxr::VtValue(false); - } - else { - return pxr::VtValue(true); - } - } + + pxr::VtValue *ret_ptr = scene_delegate_->settings.render_tokens.lookup_ptr(key); + if (ret_ptr) { + return *ret_ptr; } + return pxr::VtValue(); }