Fix #132015: Cryptomatte from image with unnamed layer fails

Cryptomatte meta-data are not loaded from EXR images with unnamed
layers. That's because the code assumed the layer is always named, and
thus had full names with a dot prefix, which didn't match the
Cryptomatte type name. To fix this, only add the dot when the layer is
named.
This commit is contained in:
Omar Emara
2024-12-19 15:47:11 +02:00
parent 5eba4313aa
commit 2bb4136e56

View File

@@ -275,9 +275,11 @@ void CachedImage::populate_meta_data(const Image *image, const ImageUser &image_
return;
}
/* We assume the given pass is a Cryptomatte pass and retrieve its layer name. If it wasn't a
/* We assume the given pass is a Cryptomatte pass and retrieve its full name. If it wasn't a
* Cryptomatte pass, the checks below will fail anyways. */
const std::string combined_pass_name = std::string(render_layer->name) + "." + render_pass->name;
const bool is_named_layer = render_layer->name[0] != '\0';
const std::string layer_prefix = is_named_layer ? std::string(render_layer->name) + "." : "";
const std::string combined_pass_name = layer_prefix + render_pass->name;
StringRef cryptomatte_layer_name = bke::cryptomatte::BKE_cryptomatte_extract_layer_name(
combined_pass_name);