diff options
author | Brecht Van Lommel <brecht@blender.org> | 2021-11-02 23:07:37 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2021-11-02 23:24:08 +0300 |
commit | f674176d7765079614d3c326616a98f9e6135207 (patch) | |
tree | dfed259c3e55a0df838bb095bc38eb8da279109f /intern/cycles/session | |
parent | a72ed0bb7fafddd87ccfb0ad7acc8a6e6fe223b0 (diff) |
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.
Diffstat (limited to 'intern/cycles/session')
-rw-r--r-- | intern/cycles/session/merge.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/intern/cycles/session/merge.cpp b/intern/cycles/session/merge.cpp index 5890c15f48c..9044a8c4809 100644 --- a/intern/cycles/session/merge.cpp +++ b/intern/cycles/session/merge.cpp @@ -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; |