diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2018-11-07 06:05:47 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2018-11-08 03:07:54 +0300 |
commit | 47c77cd89c37595c5deeb00a9235d88c460ce356 (patch) | |
tree | 6cd5402d099119ea6ac43a887d5a5903da08dcd8 /intern/cycles/render/object.cpp | |
parent | 5987c4bc579d865e96ccc6ee43789981fd4f106a (diff) |
Cycles: Write Cryptomatte metadata according to the specification
Reviewers: brecht, sergey, swerner
Subscribers: creamsurfer, Tanguy, Noss, SteffenD
Differential Revision: https://developer.blender.org/D3862
Diffstat (limited to 'intern/cycles/render/object.cpp')
-rw-r--r-- | intern/cycles/render/object.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp index a56a8a6ec58..dc7a1043208 100644 --- a/intern/cycles/render/object.cpp +++ b/intern/cycles/render/object.cpp @@ -27,6 +27,7 @@ #include "util/util_logging.h" #include "util/util_map.h" #include "util/util_progress.h" +#include "util/util_set.h" #include "util/util_vector.h" #include "util/util_murmurhash.h" @@ -844,4 +845,37 @@ void ObjectManager::tag_update(Scene *scene) scene->light_manager->need_update = true; } +string ObjectManager::get_cryptomatte_objects(Scene *scene) +{ + string manifest = "{"; + + unordered_set<ustring, ustringHash> objects; + foreach(Object *object, scene->objects) { + if(objects.count(object->name)) { + continue; + } + objects.insert(object->name); + uint32_t hash_name = util_murmur_hash3(object->name.c_str(), object->name.length(), 0); + manifest += string_printf("\"%s\":\"%08x\",", object->name.c_str(), hash_name); + } + manifest[manifest.size()-1] = '}'; + return manifest; +} + +string ObjectManager::get_cryptomatte_assets(Scene *scene) +{ + string manifest = "{"; + unordered_set<ustring, ustringHash> assets; + foreach(Object *ob, scene->objects) { + if(assets.count(ob->asset_name)) { + continue; + } + assets.insert(ob->asset_name); + uint32_t hash_asset = util_murmur_hash3(ob->asset_name.c_str(), ob->asset_name.length(), 0); + manifest += string_printf("\"%s\":\"%08x\",", ob->asset_name.c_str(), hash_asset); + } + manifest[manifest.size()-1] = '}'; + return manifest; +} + CCL_NAMESPACE_END |