[Bf-blender-cvs] [5bc4b852da7] cycles-x: Cycles X: support diffuse/glossy/transmission baking filter options

Brecht Van Lommel noreply at git.blender.org
Wed Aug 11 14:57:13 CEST 2021


Commit: 5bc4b852da7f6b1856f60569c2e4aab6f2ba82d5
Author: Brecht Van Lommel
Date:   Thu Jul 15 16:15:07 2021 +0200
Branches: cycles-x
https://developer.blender.org/rB5bc4b852da7f6b1856f60569c2e4aab6f2ba82d5

Cycles X: support diffuse/glossy/transmission baking filter options

Continue with implementing all the baking types in terms of render passes.

* Adds new pass types that combined direct and indirect light
* Add include_albedo to Pass to specify if albedo should be included
  in such light passes

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

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

M	intern/cycles/blender/blender_session.cpp
M	intern/cycles/device/device_kernel.cpp
M	intern/cycles/integrator/pass_accessor.cpp
M	intern/cycles/integrator/pass_accessor.h
M	intern/cycles/integrator/pass_accessor_cpu.cpp
M	intern/cycles/integrator/pass_accessor_cpu.h
M	intern/cycles/integrator/pass_accessor_gpu.cpp
M	intern/cycles/integrator/pass_accessor_gpu.h
M	intern/cycles/kernel/device/cuda/kernel.cu
M	intern/cycles/kernel/kernel_film.h
M	intern/cycles/kernel/kernel_types.h
M	intern/cycles/render/film.cpp
M	intern/cycles/render/pass.cpp
M	intern/cycles/render/pass.h

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

diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index 99236f20464..6fffcf1ccfe 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -573,38 +573,47 @@ static PassType bake_type_to_pass(const string &bake_type_str, const int bake_fi
     return PASS_SHADOW;
   }
   else if (strcmp(bake_type, "DIFFUSE") == 0) {
-    /* TODO: arbitrary combinations. */
-    if (bake_filter & BL::BakeSettings::pass_filter_DIRECT) {
+    if ((bake_filter & BL::BakeSettings::pass_filter_DIRECT) &&
+        bake_filter & BL::BakeSettings::pass_filter_INDIRECT) {
+      return PASS_DIFFUSE;
+    }
+    else if (bake_filter & BL::BakeSettings::pass_filter_DIRECT) {
       return PASS_DIFFUSE_DIRECT;
     }
     else if (bake_filter & BL::BakeSettings::pass_filter_INDIRECT) {
       return PASS_DIFFUSE_INDIRECT;
     }
-    else if (bake_filter & BL::BakeSettings::pass_filter_COLOR) {
+    else {
       return PASS_DIFFUSE_COLOR;
     }
   }
   else if (strcmp(bake_type, "GLOSSY") == 0) {
-    /* TODO: arbitrary combinations. */
-    if (bake_filter & BL::BakeSettings::pass_filter_DIRECT) {
+    if ((bake_filter & BL::BakeSettings::pass_filter_DIRECT) &&
+        bake_filter & BL::BakeSettings::pass_filter_INDIRECT) {
+      return PASS_GLOSSY;
+    }
+    else if (bake_filter & BL::BakeSettings::pass_filter_DIRECT) {
       return PASS_GLOSSY_DIRECT;
     }
     else if (bake_filter & BL::BakeSettings::pass_filter_INDIRECT) {
       return PASS_GLOSSY_INDIRECT;
     }
-    else if (bake_filter & BL::BakeSettings::pass_filter_COLOR) {
+    else {
       return PASS_GLOSSY_COLOR;
     }
   }
   else if (strcmp(bake_type, "TRANSMISSION") == 0) {
-    /* TODO: arbitrary combinations. */
-    if (bake_filter & BL::BakeSettings::pass_filter_DIRECT) {
+    if ((bake_filter & BL::BakeSettings::pass_filter_DIRECT) &&
+        bake_filter & BL::BakeSettings::pass_filter_INDIRECT) {
+      return PASS_TRANSMISSION;
+    }
+    else if (bake_filter & BL::BakeSettings::pass_filter_DIRECT) {
       return PASS_TRANSMISSION_DIRECT;
     }
     else if (bake_filter & BL::BakeSettings::pass_filter_INDIRECT) {
       return PASS_TRANSMISSION_INDIRECT;
     }
-    else if (bake_filter & BL::BakeSettings::pass_filter_COLOR) {
+    else {
       return PASS_TRANSMISSION_COLOR;
     }
   }
@@ -630,10 +639,10 @@ void BlenderSession::bake(BL::Depsgraph &b_depsgraph_,
 
   /* Add render pass that we want to bake, and name it Combined so that it is
    * used as that on the Blender side. */
-  const PassType pass_type = bake_type_to_pass(bake_type, bake_filter);
   Pass *pass = scene->create_node<Pass>();
-  pass->type = pass_type;
   pass->name = "Combined";
+  pass->type = bake_type_to_pass(bake_type, bake_filter);
+  pass->include_albedo = (bake_filter & BL::BakeSettings::pass_filter_COLOR);
 
   session->read_render_tile_cb = [&]() { read_render_tile(); };
   session->write_render_tile_cb = [&]() { write_render_tile(); };
diff --git a/intern/cycles/device/device_kernel.cpp b/intern/cycles/device/device_kernel.cpp
index ee3cfdb27dd..ceaddee4756 100644
--- a/intern/cycles/device/device_kernel.cpp
+++ b/intern/cycles/device/device_kernel.cpp
@@ -87,7 +87,7 @@ const char *device_kernel_as_string(DeviceKernel kernel)
       FILM_CONVERT_KERNEL_AS_STRING(MIST, mist)
       FILM_CONVERT_KERNEL_AS_STRING(SAMPLE_COUNT, sample_count)
       FILM_CONVERT_KERNEL_AS_STRING(FLOAT, float)
-      FILM_CONVERT_KERNEL_AS_STRING(DIVIDE_EVEN_COLOR, divide_even_color)
+      FILM_CONVERT_KERNEL_AS_STRING(LIGHT_PATH, light_path)
       FILM_CONVERT_KERNEL_AS_STRING(FLOAT3, float3)
       FILM_CONVERT_KERNEL_AS_STRING(MOTION, motion)
       FILM_CONVERT_KERNEL_AS_STRING(CRYPTOMATTE, cryptomatte)
diff --git a/intern/cycles/integrator/pass_accessor.cpp b/intern/cycles/integrator/pass_accessor.cpp
index ea6bd99d905..bc137195e8e 100644
--- a/intern/cycles/integrator/pass_accessor.cpp
+++ b/intern/cycles/integrator/pass_accessor.cpp
@@ -38,6 +38,7 @@ PassAccessor::PassAccessInfo::PassAccessInfo(const Pass &pass,
                                              const vector<Pass *> &passes)
     : type(pass.type),
       mode(pass.mode),
+      include_albedo(pass.include_albedo),
       offset(Pass::get_offset(passes, &pass)),
       use_approximate_shadow_catcher(film.get_use_approximate_shadow_catcher()),
       use_approximate_shadow_catcher_background(use_approximate_shadow_catcher &&
@@ -147,7 +148,7 @@ bool PassAccessor::get_render_tile_pixels(const RenderBuffers *render_buffers,
 
   const PassType type = pass_access_info_.type;
   const PassMode mode = pass_access_info_.mode;
-  const PassInfo pass_info = Pass::get_info(type);
+  const PassInfo pass_info = Pass::get_info(type, pass_access_info_.include_albedo);
 
   if (pass_info.num_components == 1) {
     /* Single channel passes. */
@@ -195,9 +196,11 @@ bool PassAccessor::get_render_tile_pixels(const RenderBuffers *render_buffers,
       /* Shadow catcher pass. */
       get_pass_shadow_catcher(render_buffers, buffer_params, destination);
     }
-    else if (pass_info.divide_type != PASS_NONE && mode != PassMode::DENOISED) {
-      /* RGB lighting passes that need to divide out color. */
-      get_pass_divide_even_color(render_buffers, buffer_params, destination);
+    else if ((pass_info.divide_type != PASS_NONE || pass_info.direct_type != PASS_NONE ||
+              pass_info.indirect_type != PASS_NONE) &&
+             mode != PassMode::DENOISED) {
+      /* RGB lighting passes that need to divide out color and/or sum direct and indirect. */
+      get_pass_light_path(render_buffers, buffer_params, destination);
     }
     else {
       /* Passes that need no special computation, or denoised passes that already
@@ -229,7 +232,8 @@ void PassAccessor::init_kernel_film_convert(KernelFilmConvert *kfilm_convert,
                                             const Destination &destination) const
 {
   const PassMode mode = pass_access_info_.mode;
-  const PassInfo &pass_info = Pass::get_info(pass_access_info_.type);
+  const PassInfo &pass_info = Pass::get_info(pass_access_info_.type,
+                                             pass_access_info_.include_albedo);
 
   kfilm_convert->pass_offset = pass_access_info_.offset;
   kfilm_convert->pass_stride = buffer_params.pass_stride;
@@ -238,7 +242,10 @@ void PassAccessor::init_kernel_film_convert(KernelFilmConvert *kfilm_convert,
   kfilm_convert->pass_use_filter = pass_info.use_filter;
 
   /* TODO(sergey): Some of the passes needs to become denoised when denoised pass is accessed. */
-
+  if (pass_info.direct_type != PASS_NONE) {
+    kfilm_convert->pass_offset = buffer_params.get_pass_offset(pass_info.direct_type);
+  }
+  kfilm_convert->pass_indirect = buffer_params.get_pass_offset(pass_info.indirect_type);
   kfilm_convert->pass_divide = buffer_params.get_pass_offset(pass_info.divide_type);
 
   kfilm_convert->pass_combined = buffer_params.get_pass_offset(PASS_COMBINED);
@@ -289,8 +296,8 @@ bool PassAccessor::set_render_tile_pixels(RenderBuffers *render_buffers, const S
     return false;
   }
 
-  const PassType type = pass_access_info_.type;
-  const PassInfo pass_info = Pass::get_info(type);
+  const PassInfo pass_info = Pass::get_info(pass_access_info_.type,
+                                            pass_access_info_.include_albedo);
 
   const BufferParams &buffer_params = render_buffers->params;
 
diff --git a/intern/cycles/integrator/pass_accessor.h b/intern/cycles/integrator/pass_accessor.h
index 6ed76e408ad..bc4768f682e 100644
--- a/intern/cycles/integrator/pass_accessor.h
+++ b/intern/cycles/integrator/pass_accessor.h
@@ -45,6 +45,7 @@ class PassAccessor {
 
     PassType type = PASS_NONE;
     PassMode mode = PassMode::NOISY;
+    bool include_albedo = false;
     int offset = -1;
 
     /* For the shadow catcher matte pass: whether to approximate shadow catcher pass into its
@@ -135,7 +136,7 @@ class PassAccessor {
   DECLARE_PASS_ACCESSOR(float)
 
   /* Float3 passes. */
-  DECLARE_PASS_ACCESSOR(divide_even_color)
+  DECLARE_PASS_ACCESSOR(light_path)
   DECLARE_PASS_ACCESSOR(shadow_catcher)
   DECLARE_PASS_ACCESSOR(float3)
 
diff --git a/intern/cycles/integrator/pass_accessor_cpu.cpp b/intern/cycles/integrator/pass_accessor_cpu.cpp
index 7ddc5cac139..83e6413b302 100644
--- a/intern/cycles/integrator/pass_accessor_cpu.cpp
+++ b/intern/cycles/integrator/pass_accessor_cpu.cpp
@@ -160,7 +160,7 @@ DEFINE_PASS_ACCESSOR(sample_count)
 DEFINE_PASS_ACCESSOR(float)
 
 /* Float3 passes. */
-DEFINE_PASS_ACCESSOR(divide_even_color)
+DEFINE_PASS_ACCESSOR(light_path)
 DEFINE_PASS_ACCESSOR(shadow_catcher)
 DEFINE_PASS_ACCESSOR(float3)
 
diff --git a/intern/cycles/integrator/pass_accessor_cpu.h b/intern/cycles/integrator/pass_accessor_cpu.h
index c4768e8ee95..0313dc5bb0d 100644
--- a/intern/cycles/integrator/pass_accessor_cpu.h
+++ b/intern/cycles/integrator/pass_accessor_cpu.h
@@ -60,7 +60,7 @@ class PassAccessorCPU : public PassAccessor {
   DECLARE_PASS_ACCESSOR(float)
 
   /* Float3 passes. */
-  DECLARE_PASS_ACCESSOR(divide_even_color)
+  DECLARE_PASS_ACCESSOR(light_path)
   DECLARE_PASS_ACCESSOR(shadow_catcher)
   DECLARE_PASS_ACCESSOR(float3)
 
diff --git a/intern/cycles/integrator/pass_accessor_gpu.cpp b/intern/cycles/integrator/pass_accessor_gpu.cpp
index 13ca783e49e..0100f8743e8 100644
--- a/intern/cycles/integrator/pass_accessor_gpu.cpp
+++ b/intern/cycles/integrator/pass_accessor_gpu.cpp
@@ -93,7 +93,7 @@ DEFINE_PASS_ACCESSOR(sample_count, SAMPLE_COUNT);
 DEFINE_PASS_ACCESSOR(float, FLOAT);
 
 /* Float3 passes. */
-DEFINE_PASS_ACCESSOR(divide_even_color, DIVIDE_EVEN_COLOR);
+DEFINE_PASS_ACCESSOR(light_path, LIGHT_PATH);
 DEFINE_PASS_ACCESSOR(float3, FLOAT3);
 
 /* Float4 passes. */
diff --git a/intern/cycles/integrator/pass_accessor_gpu.h b/intern/cycles/integrator/pass_accessor_gpu.h
index 719774e7035..bc37e4387f3 100644
--- a/intern/cycles/integrator/pass_accessor_gpu.h
+++ b/intern/cycles/integrator/pass_accessor_gpu.h
@@ -49,7 +49,7 @@ class PassAccessorGPU : public PassAccessor {
   DECLARE_PASS_ACCESSOR(float);
 
   /* Float3 passes. */
-  DECLARE_PASS_ACCESSOR(divide_even_color);
+  DECLAR

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list