Fix T85676: Cycles EXR merging not working with some single layer EXRs

If there is only a layer without a name, use metadata from the first cycles
layer in the metadata, if any.
This commit is contained in:
Brecht Van Lommel 2021-11-02 21:07:37 +01:00
parent a72ed0bb7f
commit f674176d77
Notes: blender-bot 2023-02-14 09:21:21 +01:00
Referenced by issue #85676, Cycles: EXR merger results are weird
1 changed files with 20 additions and 2 deletions

View File

@ -163,8 +163,26 @@ static bool parse_channels(const ImageSpec &in_spec,
file_layers[layername].passes.push_back(pass);
}
/* Loop over all detected render-layers, check whether they contain a full set of input channels.
* Any channels that won't be processed internally are also passed through. */
/* If file contains a single unnamed layer, name it after the first layer metadata we find. */
if (file_layers.size() == 1 && file_layers.find("") != file_layers.end()) {
for (const ParamValue &attrib : in_spec.extra_attribs) {
const string attrib_name = attrib.name().string();
if (string_startswith(attrib_name, "cycles.") && string_endswith(attrib_name, ".samples")) {
/* Extract layer name. */
const size_t start = strlen("cycles.");
const size_t end = attrib_name.size() - strlen(".samples");
const string layername = attrib_name.substr(start, end - start);
/* Reinsert as named instead of unnamed layer. */
const MergeImageLayer layer = file_layers[""];
file_layers.clear();
file_layers[layername] = layer;
}
}
}
/* Loop over all detected render-layers, check whether they contain a full set of input
* channels. Any channels that won't be processed internally are also passed through. */
for (auto &i : file_layers) {
const string &name = i.first;
MergeImageLayer &layer = i.second;