diff options
author | Jeroen Bakker <jeroen@blender.org> | 2021-02-26 16:13:15 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-02-26 16:13:15 +0300 |
commit | 87ace4682761bdeaa8f18ae12a186dbfb83d4e04 (patch) | |
tree | 2efe16601fd9b69cfaf216c816f0c9daf41d6577 /source/blender/blenkernel/BKE_cryptomatte.hh | |
parent | c489bb7c016fe4567516fbab4cc940b81f8e840f (diff) |
Cryptomatte: Manifest Parsing.
This patch adds manifest parsing to Cryptomatte. Normally when loading
cryptomatte layer from an OpenEXR file the manifest contains data to
convert a hash to its original name of the object/material. In the
future we want to use this to support lookup of cryptomatte
hashes and show it to the user.
Currently this logic isn't available to users (for now), but is required
by D3959 where a new cryptomatte workflow is implemented.
Diffstat (limited to 'source/blender/blenkernel/BKE_cryptomatte.hh')
-rw-r--r-- | source/blender/blenkernel/BKE_cryptomatte.hh | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_cryptomatte.hh b/source/blender/blenkernel/BKE_cryptomatte.hh index 4631bb2616e..c1da0339359 100644 --- a/source/blender/blenkernel/BKE_cryptomatte.hh +++ b/source/blender/blenkernel/BKE_cryptomatte.hh @@ -23,11 +23,15 @@ #pragma once +#include <optional> #include <string> +#include "BLI_map.hh" #include "BLI_string_ref.hh" -namespace blender { +struct ID; + +namespace blender::bke::cryptomatte { /* Format to a cryptomatte meta data key. * @@ -56,4 +60,30 @@ std::string BKE_cryptomatte_meta_data_key(const StringRef layer_name, */ StringRef BKE_cryptomatte_extract_layer_name(const StringRef render_pass_name); -} // namespace blender +struct CryptomatteHash { + uint32_t hash; + + CryptomatteHash(uint32_t hash); + CryptomatteHash(const char *name, const int name_len); + static CryptomatteHash from_hex_encoded(blender::StringRef hex_encoded); + + std::string hex_encoded() const; + float float_encoded() const; +}; + +struct CryptomatteLayer { + blender::Map<std::string, CryptomatteHash> hashes; + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("cryptomatte:CryptomatteLayer") +#endif + + static std::unique_ptr<CryptomatteLayer> read_from_manifest(blender::StringRefNull manifest); + uint32_t add_ID(const struct ID &id); + void add_hash(blender::StringRef name, CryptomatteHash cryptomatte_hash); + std::string manifest(); + + std::optional<std::string> operator[](float encoded_hash) const; +}; + +} // namespace blender::bke::cryptomatte |