Fix T89998: Cryptomatte node output values doubled with Multi-View

When using a Cryptomatte node and selecting 2 views in Multi-View,
its output values are doubled. When selecting 3 tripled and so on.
This causes incorrect compositing results for all the views.

The node creates an input operation for each rendered cryptomatte
pass. In Multi-View, passes are rendered for each view but compositor
is executed per view and should only create operations for those
corresponding to the current view being executed. Otherwise duplicated
operations add up later in cryptomatte operation.

Reviewed By: jbakker

Maniphest Tasks: T89998

Differential Revision: https://developer.blender.org/D12216
This commit is contained in:
Manuel Castilla 2021-08-23 15:31:21 +02:00
parent 4c6d207343
commit 7d17f2addf
Notes: blender-bot 2023-02-13 18:07:07 +01:00
Referenced by issue #96378, Selection of Bones is broken/very difficult, on moved objects Displayed As B-Bone
Referenced by issue #89998, New Cryptomatte node: matte white RGB value above 1,1,1 when using Multi-View
2 changed files with 10 additions and 0 deletions

View File

@ -239,6 +239,12 @@ class CompositorContext {
this->m_hasActiveOpenCLDevices = hasAvtiveOpenCLDevices;
}
/** Whether it has a view with a specific name and not the default one. */
bool has_explicit_view() const
{
return m_viewName && m_viewName[0] != '\0';
}
/**
* \brief get the active rendering view
*/

View File

@ -124,6 +124,10 @@ void CryptomatteNode::input_operations_from_render_source(
RenderLayer *render_layer = RE_GetRenderLayer(render_result, view_layer->name);
if (render_layer) {
LISTBASE_FOREACH (RenderPass *, render_pass, &render_layer->passes) {
if (context.has_explicit_view() && !STREQ(render_pass->view, context.getViewName())) {
continue;
}
const std::string combined_name = combined_layer_pass_name(render_layer, render_pass);
if (blender::StringRef(combined_name).startswith(prefix)) {
RenderLayersProg *op = new RenderLayersProg(