[Bf-blender-cvs] [9a8f840c317] master: Fix T72471: Cycles AOV support breaks passes with divide_type

Lukas Stockner noreply at git.blender.org
Fri Dec 20 19:58:25 CET 2019


Commit: 9a8f840c3174fa54cadfa1b475269149a3de2492
Author: Lukas Stockner
Date:   Fri Dec 20 19:49:11 2019 +0100
Branches: master
https://developer.blender.org/rB9a8f840c3174fa54cadfa1b475269149a3de2492

Fix T72471: Cycles AOV support breaks passes with divide_type

The problem is described in a comment in the change.
Short version: If a pass was used as a divide_type but also requested
explicitly (e.g. diffuse color), it was added to the passes list
twice because the names of the two requests didn't match.
Then, when searching for the pass to divide by, the wrong one (not
the one that the kernel was writing to) was picked.

===================================================================

M	intern/cycles/render/film.cpp

===================================================================

diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp
index 3cd7936ae45..bd274844b52 100644
--- a/intern/cycles/render/film.cpp
+++ b/intern/cycles/render/film.cpp
@@ -41,7 +41,34 @@ static bool compare_pass_order(const Pass &a, const Pass &b)
 void Pass::add(PassType type, vector<Pass> &passes, const char *name)
 {
   for (size_t i = 0; i < passes.size(); i++) {
-    if (passes[i].type == type && (name ? (passes[i].name == name) : passes[i].name.empty())) {
+    if (passes[i].type != type) {
+      continue;
+    }
+
+    /* An empty name is used as a placeholder to signal that any pass of
+     * that type is fine (because the content always is the same).
+     * This is important to support divide_type: If the pass that has a
+     * divide_type is added first, a pass for divide_type with an empty
+     * name will be added. Then, if a matching pass with a name is later
+     * requested, the existing placeholder will be renamed to that.
+     * If the divide_type is explicitly allocated with a name first and
+     * then again as part of another pass, the second one will just be
+     * skipped because that type already exists. */
+
+    /* If no name is specified, any pass of the correct type will match. */
+    if (name == NULL) {
+      return;
+    }
+
+    /* If we already have a placeholder pass, rename that one. */
+    if (passes[i].name.empty()) {
+      passes[i].name = name;
+      return;
+    }
+
+    /* If neither existing nor requested pass have placeholder name, they
+     * must match. */
+    if (name == passes[i].name) {
       return;
     }
   }



More information about the Bf-blender-cvs mailing list