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/blender/blender_session.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/blender/blender_session.cpp')
-rw-r--r-- | intern/cycles/blender/blender_session.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index e05351eea40..75c7dcee05e 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -35,6 +35,7 @@ #include "util/util_function.h" #include "util/util_hash.h" #include "util/util_logging.h" +#include "util/util_murmurhash.h" #include "util/util_progress.h" #include "util/util_time.h" @@ -370,6 +371,17 @@ void BlenderSession::update_render_tile(RenderTile& rtile, bool highlight) do_write_update_render_tile(rtile, false, false); } +static void add_cryptomatte_layer(BL::RenderResult& b_rr, string name, string manifest) +{ + string identifier = string_printf("%08x", util_murmur_hash3(name.c_str(), name.length(), 0)); + string prefix = "cryptomatte/" + identifier.substr(0, 7) + "/"; + + render_add_metadata(b_rr, prefix+"name", name); + render_add_metadata(b_rr, prefix+"hash", "MurmurHash3_32"); + render_add_metadata(b_rr, prefix+"conversion", "uint32_to_float32"); + render_add_metadata(b_rr, prefix+"manifest", manifest); +} + void BlenderSession::render() { /* set callback to write out render results */ @@ -477,15 +489,28 @@ void BlenderSession::render() break; } + BL::RenderResult b_full_rr = b_engine.get_result(); if(is_single_layer) { - BL::RenderResult b_rr = b_engine.get_result(); string num_aa_samples = string_printf("%d", session->params.samples); - b_rr.stamp_data_add_field("Cycles Samples", num_aa_samples.c_str()); + render_add_metadata(b_full_rr, "Cycles Samples", num_aa_samples); /* TODO(sergey): Report whether we're doing resumable render * and also start/end sample if so. */ } + if(scene->film->cryptomatte_passes & CRYPT_OBJECT) { + add_cryptomatte_layer(b_full_rr, b_rlay_name+".CryptoObject", + scene->object_manager->get_cryptomatte_objects(scene)); + } + if(scene->film->cryptomatte_passes & CRYPT_MATERIAL) { + add_cryptomatte_layer(b_full_rr, b_rlay_name+".CryptoMaterial", + scene->shader_manager->get_cryptomatte_materials(scene)); + } + if(scene->film->cryptomatte_passes & CRYPT_ASSET) { + add_cryptomatte_layer(b_full_rr, b_rlay_name+".CryptoAsset", + scene->object_manager->get_cryptomatte_assets(scene)); + } + /* free result without merging */ end_render_result(b_engine, b_rr, true, true, false); |