[Bf-blender-cvs] [f64d3a4a737] cycles-x: Fix fully transparent shadow catcher pass without catchers

Sergey Sharybin noreply at git.blender.org
Fri Jul 16 14:14:16 CEST 2021


Commit: f64d3a4a73738080df5e56df6399b6f38ff21048
Author: Sergey Sharybin
Date:   Fri Jul 16 13:41:07 2021 +0200
Branches: cycles-x
https://developer.blender.org/rBf64d3a4a73738080df5e56df6399b6f38ff21048

Fix fully transparent shadow catcher pass without catchers

Makes it so behavior of a shadow catcher pass is always predictable:
it is always possible to multiply it with a backdrop, regardless of
presence of shadow catcher object in the scene.

The downside it that this change makes it so extra memory is allocated
to store empty shadow catcher, and will make it so denoiser will an
extra work. Is possible to avoid, but it ends up in tricky checks, and
the situation is unlikely to be that common to justify making code
more complex.

Differential Revision: https://developer.blender.org/D11945

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

M	intern/cycles/integrator/denoiser_oidn.cpp
M	intern/cycles/render/pass.cpp
M	intern/cycles/render/pass.h
M	intern/cycles/render/scene.cpp

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

diff --git a/intern/cycles/integrator/denoiser_oidn.cpp b/intern/cycles/integrator/denoiser_oidn.cpp
index 29e1e85b369..ca062ee3545 100644
--- a/intern/cycles/integrator/denoiser_oidn.cpp
+++ b/intern/cycles/integrator/denoiser_oidn.cpp
@@ -215,7 +215,7 @@ class OIDNDenoiseContext {
     }
 
     OIDNPass oidn_output_pass(buffer_params_, "output", pass_type, PassMode::DENOISED);
-    if (oidn_color_pass.offset == PASS_UNUSED) {
+    if (oidn_output_pass.offset == PASS_UNUSED) {
       LOG(DFATAL) << "Missing denoised pass " << pass_type_as_string(pass_type);
       return;
     }
diff --git a/intern/cycles/render/pass.cpp b/intern/cycles/render/pass.cpp
index 66302a500ae..1feb73a3624 100644
--- a/intern/cycles/render/pass.cpp
+++ b/intern/cycles/render/pass.cpp
@@ -421,6 +421,19 @@ bool Pass::contains(const vector<Pass> &passes, PassType type, PassMode mode)
   return Pass::find(passes, type, mode) != nullptr;
 }
 
+bool Pass::contains_any(const vector<Pass> &passes, PassType type)
+{
+  for (const Pass &pass : passes) {
+    if (pass.type != type) {
+      continue;
+    }
+
+    return true;
+  }
+
+  return false;
+}
+
 void Pass::remove_all_auto(vector<Pass> &passes)
 {
   vector<Pass> new_passes;
diff --git a/intern/cycles/render/pass.h b/intern/cycles/render/pass.h
index f3ebf23f844..eb37ae0e9a9 100644
--- a/intern/cycles/render/pass.h
+++ b/intern/cycles/render/pass.h
@@ -122,6 +122,7 @@ class Pass : public Node {
       vector<Pass> &passes, PassType type, PassMode mode, int flags, const char *name = nullptr);
 
   static bool contains(const vector<Pass> &passes, PassType type, PassMode mode = PassMode::NOISY);
+  static bool contains_any(const vector<Pass> &passes, PassType type);
 
   /* Remove all passes which were automatically created. */
   static void remove_all_auto(vector<Pass> &passes);
diff --git a/intern/cycles/render/scene.cpp b/intern/cycles/render/scene.cpp
index 2f79a4a1e82..01f46c74fdd 100644
--- a/intern/cycles/render/scene.cpp
+++ b/intern/cycles/render/scene.cpp
@@ -591,6 +591,12 @@ void Scene::update_passes()
       Pass::add_internal(passes, PASS_SHADOW_CATCHER_MATTE, PassMode::DENOISED, Pass::FLAG_AUTO);
     }
   }
+  else if (Pass::contains_any(passes, PASS_SHADOW_CATCHER)) {
+    Pass::add_internal(passes, PASS_SHADOW_CATCHER, Pass::FLAG_AUTO);
+    if (add_denoised_passes) {
+      Pass::add_internal(passes, PASS_SHADOW_CATCHER, PassMode::DENOISED, Pass::FLAG_AUTO);
+    }
+  }
 
   film->tag_modified();



More information about the Bf-blender-cvs mailing list