Fix T64953: Add cryptomatte meta data to file output node.

This change will try to add meta data when using a multilayered open
exr file output node in the compositor. It adds the current scene meta
data and converts existing cryptomatte keys so it follows the
naming that is configured in the file output node.

This change supports the basic use-case where the compositor is
used to output cryptomatte layers with a different naming scheme to
support external compositors. In this case the Multilayered OpenEXR
files are used and the meta data is read from the render result.

Meta data is found when render layer node is connected with the
file output node without any other nodes in between. Redirects and empty
node groups are allowed.

The patch has been verified to work with external compositors.
See https://devtalk.blender.org/t/making-sense-of-cryptomatte-usage-in-third-party-programs/16576/17

See patch for example files.

Reviewed By: Sergey Sharybin

Differential Revision: https://developer.blender.org/D10016
This commit is contained in:
Jeroen Bakker 2021-01-12 16:19:54 +01:00
parent c3b68fa7b1
commit 957e292c58
Notes: blender-bot 2023-02-14 02:30:08 +01:00
Referenced by commit 36f0a1ead7, Fix T84823: crash rendering with unconnected input socket in File Output node
Referenced by issue #84823, Adding more inputs to the File Output node and then hit render crashes Blender
Referenced by issue #64953, Cryptomatte - File Output node is messing up the multilayer exr (metadata), so blender cryptomattes cannot be read properly in external compositors
17 changed files with 438 additions and 22 deletions

View File

@ -0,0 +1,59 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2020 Blender Foundation.
* All rights reserved.
*/
/** \file
* \ingroup bke
*/
#pragma once
#include <string>
#include "BLI_string_ref.hh"
namespace blender {
/* Format to a cryptomatte meta data key.
*
* Cryptomatte stores meta data. The keys are formatted containing a hash that
* is generated from its layer name.
*
* The output of this function is:
* 'cryptomatte/{hash of layer_name}/{key_name}'.
*/
std::string BKE_cryptomatte_meta_data_key(const StringRef layer_name,
const StringRefNull key_name);
/* Extract the cryptomatte layer name from the given `render_pass_name`.
*
* Cryptomatte passes are formatted with a trailing number for storing multiple samples that belong
* to the same cryptomatte layer. This function would remove the trailing numbers to determine the
* cryptomatte layer name.
*
* # Example
*
* A render_pass_name could be 'View Layer.CryptoMaterial02'. The cryptomatte layer would be 'View
* Layer.CryptoMaterial'.
*
* NOTE: The return type is a substring of `render_pass_name` and therefore cannot outlive the
* `render_pass_name` internal data.
*/
StringRef BKE_cryptomatte_extract_layer_name(const StringRef render_pass_name);
} // namespace blender

View File

@ -731,6 +731,7 @@ add_dependencies(bf_blenkernel bf_dna)
if(WITH_GTESTS)
set(TEST_SRC
intern/armature_test.cc
intern/cryptomatte_test.cc
intern/fcurve_test.cc
intern/lattice_deform_test.cc
intern/layer_test.cc

View File

@ -22,6 +22,7 @@
*/
#include "BKE_cryptomatte.h"
#include "BKE_cryptomatte.hh"
#include "BKE_image.h"
#include "BKE_main.h"
@ -43,6 +44,7 @@
#include <iomanip>
#include <sstream>
#include <string>
#include <string_view>
enum CryptomatteLayerState {
EMPTY,
@ -299,15 +301,15 @@ static uint32_t cryptomatte_determine_identifier(const std::string name)
return BLI_hash_mm3(reinterpret_cast<const unsigned char *>(name.c_str()), name.length(), 0);
}
static std::string cryptomatte_determine_prefix(const std::string name)
static void add_render_result_meta_data(RenderResult *render_result,
const blender::StringRef layer_name,
const blender::StringRefNull key_name,
const blender::StringRefNull value)
{
std::stringstream stream;
const uint32_t render_pass_identifier = cryptomatte_determine_identifier(name);
stream << "cryptomatte/";
stream << std::setfill('0') << std::setw(sizeof(uint32_t) * 2) << std::hex
<< render_pass_identifier;
stream << "/";
return stream.str();
BKE_render_result_stamp_data(
render_result,
blender::BKE_cryptomatte_meta_data_key(layer_name, key_name).c_str(),
value.data());
}
void BKE_cryptomatte_store_metadata(struct CryptomatteSession *session,
@ -335,12 +337,47 @@ void BKE_cryptomatte_store_metadata(struct CryptomatteSession *session,
const std::string manifest = layer->manifest_get_string();
const std::string name = cryptomatte_determine_name(view_layer, cryptomatte_layer_name);
const std::string prefix = cryptomatte_determine_prefix(name);
/* Store the meta data into the render result. */
BKE_render_result_stamp_data(render_result, (prefix + "name").c_str(), name.c_str());
BKE_render_result_stamp_data(render_result, (prefix + "hash").c_str(), "MurmurHash3_32");
BKE_render_result_stamp_data(
render_result, (prefix + "conversion").c_str(), "uint32_to_float32");
BKE_render_result_stamp_data(render_result, (prefix + "manifest").c_str(), manifest.c_str());
add_render_result_meta_data(render_result, name, "name", name);
add_render_result_meta_data(render_result, name, "hash", "MurmurHash3_32");
add_render_result_meta_data(render_result, name, "conversion", "uint32_to_float32");
add_render_result_meta_data(render_result, name, "manifest", manifest);
}
namespace blender {
/* Return the hash of the given cryptomatte layer name.
*
* The cryptomatte specification limits the hash to 7 characters.
* The 7 position limitation solves issues when using cryptomatte together with OpenEXR.
* The specification suggests to use the first 7 chars of the hashed layer_name.
*/
static std::string cryptomatte_layer_name_hash(const StringRef layer_name)
{
std::stringstream stream;
const uint32_t render_pass_identifier = cryptomatte_determine_identifier(layer_name);
stream << std::setfill('0') << std::setw(sizeof(uint32_t) * 2) << std::hex
<< render_pass_identifier;
return stream.str().substr(0, 7);
}
std::string BKE_cryptomatte_meta_data_key(const StringRef layer_name, const StringRefNull key_name)
{
return "cryptomatte/" + cryptomatte_layer_name_hash(layer_name) + "/" + key_name;
}
/* Extracts the cryptomatte name from a render pass name.
*
* Example: A render pass could be named `CryptoObject00`. This
* function would remove the trailing digits and return `CryptoObject`. */
StringRef BKE_cryptomatte_extract_layer_name(const StringRef render_pass_name)
{
int64_t last_token = render_pass_name.size();
while (last_token > 0 && std::isdigit(render_pass_name[last_token - 1])) {
last_token -= 1;
}
return render_pass_name.substr(0, last_token);
}
} // namespace blender

View File

@ -0,0 +1,44 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2021 by Blender Foundation.
*/
#include "testing/testing.h"
#include "BKE_cryptomatte.hh"
namespace blender::bke::tests {
TEST(cryptomatte, meta_data_key)
{
ASSERT_EQ("cryptomatte/c7dbf5e/key",
BKE_cryptomatte_meta_data_key("ViewLayer.CryptoMaterial", "key"));
ASSERT_EQ("cryptomatte/b990b65/𝓴𝓮𝔂",
BKE_cryptomatte_meta_data_key("𝖚𝖓𝖎𝖈𝖔𝖉𝖊.CryptoMaterial", "𝓴𝓮𝔂"));
}
TEST(cryptomatte, extract_layer_name)
{
ASSERT_EQ("ViewLayer.CryptoMaterial",
BKE_cryptomatte_extract_layer_name("ViewLayer.CryptoMaterial00"));
ASSERT_EQ("𝖚𝖓𝖎𝖈𝖔𝖉𝖊", BKE_cryptomatte_extract_layer_name("𝖚𝖓𝖎𝖈𝖔𝖉𝖊13"));
ASSERT_EQ("NoTrailingSampleNumber",
BKE_cryptomatte_extract_layer_name("NoTrailingSampleNumber"));
ASSERT_EQ("W1thM1dd13Numb3rs", BKE_cryptomatte_extract_layer_name("W1thM1dd13Numb3rs09"));
ASSERT_EQ("", BKE_cryptomatte_extract_layer_name("0123"));
ASSERT_EQ("", BKE_cryptomatte_extract_layer_name(""));
}
} // namespace blender::bke::tests

View File

@ -71,6 +71,8 @@ set(SRC
intern/COM_MemoryBuffer.h
intern/COM_MemoryProxy.cpp
intern/COM_MemoryProxy.h
intern/COM_MetaData.cpp
intern/COM_MetaData.h
intern/COM_Node.cpp
intern/COM_Node.h
intern/COM_NodeConverter.cpp

View File

@ -0,0 +1,71 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright 2021, Blender Foundation.
*/
#include "COM_MetaData.h"
#include "BKE_cryptomatte.hh"
#include "BKE_image.h"
#include "RE_pipeline.h"
#include <string_view>
void MetaData::add(const blender::StringRef key, const blender::StringRef value)
{
entries_.add(key, value);
}
void MetaData::addCryptomatteEntry(const blender::StringRef layer_name,
const blender::StringRefNull key,
const blender::StringRef value)
{
add(blender::BKE_cryptomatte_meta_data_key(layer_name, key), value);
}
/* Replace the hash neutral cryptomatte keys with hashed versions.
*
* When a conversion happens it will also add the cryptomatte name key with the given
* `layer_name`.*/
void MetaData::replaceHashNeutralCryptomatteKeys(const blender::StringRef layer_name)
{
std::string cryptomatte_hash = entries_.pop_default(META_DATA_KEY_CRYPTOMATTE_HASH, "");
std::string cryptomatte_conversion = entries_.pop_default(META_DATA_KEY_CRYPTOMATTE_CONVERSION,
"");
std::string cryptomatte_manifest = entries_.pop_default(META_DATA_KEY_CRYPTOMATTE_MANIFEST, "");
if (cryptomatte_hash.length() || cryptomatte_conversion.length() ||
cryptomatte_manifest.length()) {
addCryptomatteEntry(layer_name, "name", layer_name);
}
if (cryptomatte_hash.length()) {
addCryptomatteEntry(layer_name, "hash", cryptomatte_hash);
}
if (cryptomatte_conversion.length()) {
addCryptomatteEntry(layer_name, "conversion", cryptomatte_conversion);
}
if (cryptomatte_manifest.length()) {
addCryptomatteEntry(layer_name, "manifest", cryptomatte_manifest);
}
}
void MetaData::addToRenderResult(RenderResult *render_result) const
{
for (blender::Map<std::string, std::string>::Item entry : entries_.items()) {
BKE_render_result_stamp_data(render_result, entry.key.c_str(), entry.value.c_str());
}
}

View File

@ -0,0 +1,56 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright 2021, Blender Foundation.
*/
#pragma once
#include <string>
#include "BLI_map.hh"
#include "MEM_guardedalloc.h"
/* Forward declarations. */
struct StampData;
struct RenderResult;
/* Cryptomatte includes hash in its meta data keys. The hash is generated from the render
* layer/pass name. Compositing happens without the knowledge of the original layer and pass. The
* next keys are used to transfer the cryptomatte meta data in a neutral way. The file output node
* will generate a hash based on the layer name configured by the user.
*
* The `{hash}` has no special meaning except to make sure that the meta data stays unique. */
constexpr blender::StringRef META_DATA_KEY_CRYPTOMATTE_HASH("cryptomatte/{hash}/hash");
constexpr blender::StringRef META_DATA_KEY_CRYPTOMATTE_CONVERSION("cryptomatte/{hash}/conversion");
constexpr blender::StringRef META_DATA_KEY_CRYPTOMATTE_MANIFEST("cryptomatte/{hash}/manifest");
constexpr blender::StringRef META_DATA_KEY_CRYPTOMATTE_NAME("cryptomatte/{hash}/name");
class MetaData {
private:
blender::Map<std::string, std::string> entries_;
void addCryptomatteEntry(const blender::StringRef layer_name,
const blender::StringRefNull key,
const blender::StringRef value);
public:
void add(const blender::StringRef key, const blender::StringRef value);
void replaceHashNeutralCryptomatteKeys(const blender::StringRef layer_name);
void addToRenderResult(RenderResult *render_result) const;
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:MetaData")
#endif
};

View File

@ -19,8 +19,12 @@
#pragma once
#include "BLI_rect.h"
#include "COM_MetaData.h"
#include "COM_defines.h"
#include <memory>
#include <optional>
#ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h"
#endif
@ -32,6 +36,7 @@ typedef enum PixelSampler {
} PixelSampler;
class MemoryBuffer;
/**
* \brief Helper class for reading socket data.
* Only use this class for dispatching (un-ary and n-ary) executions.
@ -134,6 +139,14 @@ class SocketReader {
return this->m_height;
}
/* Return the meta data associated with this branch.
*
* The return parameter holds an instance or is an nullptr. */
virtual std::unique_ptr<MetaData> getMetaData() const
{
return std::unique_ptr<MetaData>();
}
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:SocketReader")
#endif

View File

@ -50,7 +50,8 @@ void OutputFileNode::convertToOperations(NodeConverter &converter,
OutputOpenExrMultiLayerOperation *outputOperation;
if (is_multiview && storage->format.views_format == R_IMF_VIEWS_MULTIVIEW) {
outputOperation = new OutputOpenExrMultiLayerMultiViewOperation(context.getRenderData(),
outputOperation = new OutputOpenExrMultiLayerMultiViewOperation(context.getScene(),
context.getRenderData(),
context.getbNodeTree(),
storage->base_path,
storage->format.exr_codec,
@ -58,7 +59,8 @@ void OutputFileNode::convertToOperations(NodeConverter &converter,
context.getViewName());
}
else {
outputOperation = new OutputOpenExrMultiLayerOperation(context.getRenderData(),
outputOperation = new OutputOpenExrMultiLayerOperation(context.getScene(),
context.getRenderData(),
context.getbNodeTree(),
storage->base_path,
storage->format.exr_codec,

View File

@ -143,13 +143,14 @@ void OutputOpenExrSingleLayerMultiViewOperation::deinitExecution()
/************************************ OpenEXR Multilayer Multiview *******************************/
OutputOpenExrMultiLayerMultiViewOperation::OutputOpenExrMultiLayerMultiViewOperation(
const Scene *scene,
const RenderData *rd,
const bNodeTree *tree,
const char *path,
char exr_codec,
bool exr_half_float,
const char *viewName)
: OutputOpenExrMultiLayerOperation(rd, tree, path, exr_codec, exr_half_float, viewName)
: OutputOpenExrMultiLayerOperation(scene, rd, tree, path, exr_codec, exr_half_float, viewName)
{
}
@ -195,12 +196,16 @@ void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filename
BLI_make_existing_file(filename);
/* prepare the file with all the channels for the header */
if (IMB_exr_begin_write(exrhandle, filename, width, height, this->m_exr_codec, nullptr) == 0) {
StampData *stamp_data = createStampData();
if (IMB_exr_begin_write(exrhandle, filename, width, height, this->m_exr_codec, stamp_data) ==
0) {
printf("Error Writing Multilayer Multiview Openexr\n");
IMB_exr_close(exrhandle);
BKE_stamp_data_free(stamp_data);
}
else {
IMB_exr_clear_channels(exrhandle);
BKE_stamp_data_free(stamp_data);
return exrhandle;
}
}

View File

@ -48,7 +48,8 @@ class OutputOpenExrSingleLayerMultiViewOperation : public OutputSingleLayerOpera
class OutputOpenExrMultiLayerMultiViewOperation : public OutputOpenExrMultiLayerOperation {
private:
public:
OutputOpenExrMultiLayerMultiViewOperation(const RenderData *rd,
OutputOpenExrMultiLayerMultiViewOperation(const Scene *scene,
const RenderData *rd,
const bNodeTree *tree,
const char *path,
char exr_codec,

View File

@ -18,12 +18,15 @@
#include "COM_OutputFileOperation.h"
#include "COM_MetaData.h"
#include <cstring>
#include "BLI_listbase.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "BKE_cryptomatte.hh"
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_main.h"
@ -36,6 +39,8 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "RE_pipeline.h"
void add_exr_channels(void *exrhandle,
const char *layerName,
const DataType datatype,
@ -299,13 +304,15 @@ OutputOpenExrLayer::OutputOpenExrLayer(const char *name_, DataType datatype_, bo
this->imageInput = nullptr;
}
OutputOpenExrMultiLayerOperation::OutputOpenExrMultiLayerOperation(const RenderData *rd,
OutputOpenExrMultiLayerOperation::OutputOpenExrMultiLayerOperation(const Scene *scene,
const RenderData *rd,
const bNodeTree *tree,
const char *path,
char exr_codec,
bool exr_half_float,
const char *viewName)
{
this->m_scene = scene;
this->m_rd = rd;
this->m_tree = tree;
@ -323,6 +330,26 @@ void OutputOpenExrMultiLayerOperation::add_layer(const char *name,
this->m_layers.push_back(OutputOpenExrLayer(name, datatype, use_layer));
}
StampData *OutputOpenExrMultiLayerOperation::createStampData() const
{
/* StampData API doesn't provide functions to modify an instance without having a RenderResult.
*/
RenderResult render_result;
StampData *stamp_data = BKE_stamp_info_from_scene_static(m_scene);
render_result.stamp_data = stamp_data;
for (int i = 0; i < this->m_layers.size(); i++) {
const OutputOpenExrLayer *layer = &this->m_layers[i];
std::unique_ptr<MetaData> meta_data = layer->imageInput->getMetaData();
if (meta_data) {
blender::StringRef layer_name = blender::BKE_cryptomatte_extract_layer_name(
blender::StringRef(layer->name, BLI_strnlen(layer->name, sizeof(layer->name))));
meta_data->replaceHashNeutralCryptomatteKeys(layer_name);
meta_data->addToRenderResult(&render_result);
}
}
return stamp_data;
}
void OutputOpenExrMultiLayerOperation::initExecution()
{
for (unsigned int i = 0; i < this->m_layers.size(); i++) {
@ -386,7 +413,8 @@ void OutputOpenExrMultiLayerOperation::deinitExecution()
}
/* when the filename has no permissions, this can fail */
if (IMB_exr_begin_write(exrhandle, filename, width, height, this->m_exr_codec, nullptr)) {
StampData *stamp_data = createStampData();
if (IMB_exr_begin_write(exrhandle, filename, width, height, this->m_exr_codec, stamp_data)) {
IMB_exr_write_channels(exrhandle);
}
else {
@ -404,5 +432,6 @@ void OutputOpenExrMultiLayerOperation::deinitExecution()
this->m_layers[i].imageInput = nullptr;
}
BKE_stamp_data_free(stamp_data);
}
}

View File

@ -91,6 +91,7 @@ class OutputOpenExrMultiLayerOperation : public NodeOperation {
protected:
typedef std::vector<OutputOpenExrLayer> LayerList;
const Scene *m_scene;
const RenderData *m_rd;
const bNodeTree *m_tree;
@ -100,8 +101,11 @@ class OutputOpenExrMultiLayerOperation : public NodeOperation {
LayerList m_layers;
const char *m_viewName;
StampData *createStampData() const;
public:
OutputOpenExrMultiLayerOperation(const RenderData *rd,
OutputOpenExrMultiLayerOperation(const Scene *scene,
const RenderData *rd,
const bNodeTree *tree,
const char *path,
char exr_codec,

View File

@ -18,8 +18,16 @@
#include "COM_RenderLayersProg.h"
#include "COM_MetaData.h"
#include "BKE_cryptomatte.hh"
#include "BKE_image.h"
#include "BKE_scene.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_string_ref.hh"
#include "DNA_scene_types.h"
#include "RE_pipeline.h"
@ -209,6 +217,82 @@ void RenderLayersProg::determineResolution(unsigned int resolution[2],
}
}
struct CallbackData {
std::unique_ptr<MetaData> meta_data;
std::string hash_key;
std::string conversion_key;
std::string manifest_key;
void addMetaData(blender::StringRef key, blender::StringRefNull value)
{
if (!meta_data) {
meta_data = std::make_unique<MetaData>();
}
meta_data->add(key, value);
}
void setCryptomatteKeys(blender::StringRef cryptomatte_layer_name)
{
manifest_key = blender::BKE_cryptomatte_meta_data_key(cryptomatte_layer_name, "manifest");
hash_key = blender::BKE_cryptomatte_meta_data_key(cryptomatte_layer_name, "hash");
conversion_key = blender::BKE_cryptomatte_meta_data_key(cryptomatte_layer_name, "conversion");
}
};
/* C type callback function (StampCallback). */
static void extract_cryptomatte_meta_data(void *_data,
const char *propname,
char *propvalue,
int UNUSED(len))
{
CallbackData *data = static_cast<CallbackData *>(_data);
blender::StringRefNull key(propname);
if (key == data->hash_key) {
data->addMetaData(META_DATA_KEY_CRYPTOMATTE_HASH, propvalue);
}
else if (key == data->conversion_key) {
data->addMetaData(META_DATA_KEY_CRYPTOMATTE_CONVERSION, propvalue);
}
else if (key == data->manifest_key) {
data->addMetaData(META_DATA_KEY_CRYPTOMATTE_MANIFEST, propvalue);
}
}
std::unique_ptr<MetaData> RenderLayersProg::getMetaData() const
{
Scene *scene = this->getScene();
Render *re = (scene) ? RE_GetSceneRender(scene) : nullptr;
RenderResult *rr = nullptr;
CallbackData callback_data = {nullptr};
if (re) {
rr = RE_AcquireResultRead(re);
}
if (rr && rr->stamp_data) {
ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&scene->view_layers, getLayerId());
if (view_layer) {
std::string full_layer_name = std::string(
view_layer->name,
BLI_strnlen(view_layer->name, sizeof(view_layer->name))) +
"." + m_passName;
blender::StringRef cryptomatte_layer_name = blender::BKE_cryptomatte_extract_layer_name(
full_layer_name);
callback_data.setCryptomatteKeys(cryptomatte_layer_name);
BKE_stamp_info_callback(
&callback_data, rr->stamp_data, extract_cryptomatte_meta_data, false);
}
}
if (re) {
RE_ReleaseResult(re);
re = nullptr;
}
return std::move(callback_data.meta_data);
}
/* ******** Render Layers AO Operation ******** */
void RenderLayersAOOperation::executePixelSampled(float output[4],
float x,

View File

@ -121,6 +121,8 @@ class RenderLayersProg : public NodeOperation {
void initExecution();
void deinitExecution();
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
std::unique_ptr<MetaData> getMetaData() const override;
};
class RenderLayersAOOperation : public RenderLayersProg {

View File

@ -24,3 +24,8 @@ SocketProxyOperation::SocketProxyOperation(DataType type, bool use_conversion)
this->addInputSocket(type);
this->addOutputSocket(type);
}
std::unique_ptr<MetaData> SocketProxyOperation::getMetaData() const
{
return this->getInputSocket(0)->getReader()->getMetaData();
}

View File

@ -41,6 +41,7 @@ class SocketProxyOperation : public NodeOperation {
{
m_use_conversion = use_conversion;
}
std::unique_ptr<MetaData> getMetaData() const override;
private:
bool m_use_conversion;