[Bf-blender-cvs] [1da0685076b] master: Cycles: add a Pass Node

Kévin Dietrich noreply at git.blender.org
Tue Aug 18 14:37:20 CEST 2020


Commit: 1da0685076bbddaaa9eb20366f07b5d552f03eb4
Author: Kévin Dietrich
Date:   Tue Aug 18 12:15:46 2020 +0200
Branches: master
https://developer.blender.org/rB1da0685076bbddaaa9eb20366f07b5d552f03eb4

Cycles: add a Pass Node

The Pass struct is now a Node and the passes are moved from the Film
class to the Scene class.

The Pass Node only has `type` and `name` as sockets as those seem to be
the only properties settable by exporters (other properties are implicit
and depend on the pass type).

This is part of T79131.

Reviewed By: brecht

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

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

M	intern/cycles/blender/blender_session.cpp
M	intern/cycles/blender/blender_sync.cpp
M	intern/cycles/render/bake.cpp
M	intern/cycles/render/film.cpp
M	intern/cycles/render/film.h
M	intern/cycles/render/integrator.cpp
M	intern/cycles/render/nodes.cpp
M	intern/cycles/render/scene.cpp
M	intern/cycles/render/scene.h

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

diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index a06030c8b7d..fb704b2a24a 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -645,7 +645,7 @@ void BlenderSession::bake(BL::Depsgraph &b_depsgraph_,
 
   /* Passes are identified by name, so in order to return the combined pass we need to set the
    * name. */
-  Pass::add(PASS_COMBINED, scene->film->passes, "Combined");
+  Pass::add(PASS_COMBINED, scene->passes, "Combined");
 
   session->read_bake_tile_cb = function_bind(&BlenderSession::read_render_tile, this, _1);
   session->write_render_tile_cb = function_bind(&BlenderSession::write_render_tile, this, _1);
@@ -678,7 +678,7 @@ void BlenderSession::bake(BL::Depsgraph &b_depsgraph_,
     BufferParams buffer_params;
     buffer_params.width = bake_width;
     buffer_params.height = bake_height;
-    buffer_params.passes = scene->film->passes;
+    buffer_params.passes = scene->passes;
 
     /* Update session. */
     session->tile_manager.set_samples(session_params.samples);
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index 511061db08a..f0b5ab087bb 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -372,8 +372,10 @@ void BlenderSync::sync_film(BL::SpaceView3D &b_v3d)
   Film *film = scene->film;
   Film prevfilm = *film;
 
+  vector<Pass> prevpasses = scene->passes;
+
   if (b_v3d) {
-    film->display_pass = update_viewport_display_passes(b_v3d, film->passes);
+    film->display_pass = update_viewport_display_passes(b_v3d, scene->passes);
   }
 
   film->exposure = get_float(cscene, "film_exposure");
@@ -403,7 +405,11 @@ void BlenderSync::sync_film(BL::SpaceView3D &b_v3d)
 
   if (film->modified(prevfilm)) {
     film->tag_update(scene);
-    film->tag_passes_update(scene, prevfilm.passes, false);
+  }
+
+  if (!Pass::equals(prevpasses, scene->passes)) {
+    film->tag_passes_update(scene, prevpasses, false);
+    film->tag_update(scene);
   }
 }
 
diff --git a/intern/cycles/render/bake.cpp b/intern/cycles/render/bake.cpp
index 6044182a51a..c00451e931f 100644
--- a/intern/cycles/render/bake.cpp
+++ b/intern/cycles/render/bake.cpp
@@ -97,17 +97,17 @@ void BakeManager::set(Scene *scene,
   type = type_;
   pass_filter = shader_type_to_pass_filter(type_, pass_filter_);
 
-  Pass::add(PASS_BAKE_PRIMITIVE, scene->film->passes);
-  Pass::add(PASS_BAKE_DIFFERENTIAL, scene->film->passes);
+  Pass::add(PASS_BAKE_PRIMITIVE, scene->passes);
+  Pass::add(PASS_BAKE_DIFFERENTIAL, scene->passes);
 
   if (type == SHADER_EVAL_UV) {
     /* force UV to be available */
-    Pass::add(PASS_UV, scene->film->passes);
+    Pass::add(PASS_UV, scene->passes);
   }
 
   /* force use_light_pass to be true if we bake more than just colors */
   if (pass_filter & ~BAKE_FILTER_COLOR) {
-    Pass::add(PASS_LIGHT, scene->film->passes);
+    Pass::add(PASS_LIGHT, scene->passes);
   }
 
   /* create device and update scene */
diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp
index d7cbf4a3581..7072fff4892 100644
--- a/intern/cycles/render/film.cpp
+++ b/intern/cycles/render/film.cpp
@@ -38,6 +38,60 @@ static bool compare_pass_order(const Pass &a, const Pass &b)
   return (a.components > b.components);
 }
 
+NODE_DEFINE(Pass)
+{
+  NodeType *type = NodeType::add("pass", create);
+
+  static NodeEnum pass_type_enum;
+  pass_type_enum.insert("combined", PASS_COMBINED);
+  pass_type_enum.insert("depth", PASS_DEPTH);
+  pass_type_enum.insert("normal", PASS_NORMAL);
+  pass_type_enum.insert("uv", PASS_UV);
+  pass_type_enum.insert("object_id", PASS_OBJECT_ID);
+  pass_type_enum.insert("material_id", PASS_MATERIAL_ID);
+  pass_type_enum.insert("motion", PASS_MOTION);
+  pass_type_enum.insert("motion_weight", PASS_MOTION_WEIGHT);
+#ifdef __KERNEL_DEBUG__
+  pass_type_enum.insert("traversed_nodes", PASS_BVH_TRAVERSED_NODES);
+  pass_type_enum.insert("traverse_instances", PASS_BVH_TRAVERSED_INSTANCES);
+  pass_type_enum.insert("bvh_intersections", PASS_BVH_INTERSECTIONS);
+  pass_type_enum.insert("ray_bounces", PASS_RAY_BOUNCES);
+#endif
+  pass_type_enum.insert("render_time", PASS_RENDER_TIME);
+  pass_type_enum.insert("cryptomatte", PASS_CRYPTOMATTE);
+  pass_type_enum.insert("aov_color", PASS_AOV_COLOR);
+  pass_type_enum.insert("aov_value", PASS_AOV_VALUE);
+  pass_type_enum.insert("adaptive_aux_buffer", PASS_ADAPTIVE_AUX_BUFFER);
+  pass_type_enum.insert("sample_count", PASS_SAMPLE_COUNT);
+  pass_type_enum.insert("mist", PASS_MIST);
+  pass_type_enum.insert("emission", PASS_EMISSION);
+  pass_type_enum.insert("background", PASS_BACKGROUND);
+  pass_type_enum.insert("ambient_occlusion", PASS_AO);
+  pass_type_enum.insert("shadow", PASS_SHADOW);
+  pass_type_enum.insert("diffuse_direct", PASS_DIFFUSE_DIRECT);
+  pass_type_enum.insert("diffuse_indirect", PASS_DIFFUSE_INDIRECT);
+  pass_type_enum.insert("diffuse_color", PASS_DIFFUSE_COLOR);
+  pass_type_enum.insert("glossy_direct", PASS_GLOSSY_DIRECT);
+  pass_type_enum.insert("glossy_indirect", PASS_GLOSSY_INDIRECT);
+  pass_type_enum.insert("glossy_color", PASS_GLOSSY_COLOR);
+  pass_type_enum.insert("transmission_direct", PASS_TRANSMISSION_DIRECT);
+  pass_type_enum.insert("transmission_indirect", PASS_TRANSMISSION_INDIRECT);
+  pass_type_enum.insert("transmission_color", PASS_TRANSMISSION_COLOR);
+  pass_type_enum.insert("volume_direct", PASS_VOLUME_DIRECT);
+  pass_type_enum.insert("volume_indirect", PASS_VOLUME_INDIRECT);
+  pass_type_enum.insert("bake_primitive", PASS_BAKE_PRIMITIVE);
+  pass_type_enum.insert("bake_differential", PASS_BAKE_DIFFERENTIAL);
+
+  SOCKET_ENUM(type, "Type", pass_type_enum, PASS_COMBINED);
+  SOCKET_STRING(name, "Name", ustring());
+
+  return type;
+}
+
+Pass::Pass() : Node(node_type)
+{
+}
+
 void Pass::add(PassType type, vector<Pass> &passes, const char *name)
 {
   for (size_t i = 0; i < passes.size(); i++) {
@@ -330,8 +384,6 @@ NODE_DEFINE(Film)
 
 Film::Film() : Node(node_type)
 {
-  Pass::add(PASS_COMBINED, passes);
-
   use_light_visibility = false;
   filter_table_offset = TABLE_OFFSET_INVALID;
   cryptomatte_passes = CRYPT_NONE;
@@ -344,6 +396,11 @@ Film::~Film()
 {
 }
 
+void Film::add_default(Scene *scene)
+{
+  Pass::add(PASS_COMBINED, scene->passes);
+}
+
 void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
 {
   if (!need_update)
@@ -371,8 +428,8 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
 
   bool have_cryptomatte = false;
 
-  for (size_t i = 0; i < passes.size(); i++) {
-    Pass &pass = passes[i];
+  for (size_t i = 0; i < scene->passes.size(); i++) {
+    Pass &pass = scene->passes[i];
 
     if (pass.type == PASS_NONE) {
       continue;
@@ -601,26 +658,26 @@ void Film::device_free(Device * /*device*/, DeviceScene * /*dscene*/, Scene *sce
 
 bool Film::modified(const Film &film)
 {
-  return !Node::equals(film) || !Pass::equals(passes, film.passes);
+  return !Node::equals(film);
 }
 
 void Film::tag_passes_update(Scene *scene, const vector<Pass> &passes_, bool update_passes)
 {
-  if (Pass::contains(passes, PASS_UV) != Pass::contains(passes_, PASS_UV)) {
+  if (Pass::contains(scene->passes, PASS_UV) != Pass::contains(passes_, PASS_UV)) {
     scene->geometry_manager->tag_update(scene);
 
     foreach (Shader *shader, scene->shaders)
       shader->need_update_geometry = true;
   }
-  else if (Pass::contains(passes, PASS_MOTION) != Pass::contains(passes_, PASS_MOTION)) {
+  else if (Pass::contains(scene->passes, PASS_MOTION) != Pass::contains(passes_, PASS_MOTION)) {
     scene->geometry_manager->tag_update(scene);
   }
-  else if (Pass::contains(passes, PASS_AO) != Pass::contains(passes_, PASS_AO)) {
+  else if (Pass::contains(scene->passes, PASS_AO) != Pass::contains(passes_, PASS_AO)) {
     scene->integrator->tag_update(scene);
   }
 
   if (update_passes) {
-    passes = passes_;
+    scene->passes = passes_;
   }
 }
 
@@ -629,10 +686,10 @@ void Film::tag_update(Scene * /*scene*/)
   need_update = true;
 }
 
-int Film::get_aov_offset(string name, bool &is_color)
+int Film::get_aov_offset(Scene *scene, string name, bool &is_color)
 {
   int num_color = 0, num_value = 0;
-  foreach (const Pass &pass, passes) {
+  foreach (const Pass &pass, scene->passes) {
     if (pass.type == PASS_AOV_COLOR) {
       num_color++;
     }
diff --git a/intern/cycles/render/film.h b/intern/cycles/render/film.h
index aae8fb404b0..961058c008e 100644
--- a/intern/cycles/render/film.h
+++ b/intern/cycles/render/film.h
@@ -38,14 +38,18 @@ typedef enum FilterType {
   FILTER_NUM_TYPES,
 } FilterType;
 
-class Pass {
+class Pass : public Node {
  public:
+  NODE_DECLARE
+
+  Pass();
+
   PassType type;
   int components;
   bool filter;
   bool exposure;
   PassType divide_type;
-  string name;
+  ustring name;
 
   static void add(PassType type, vector<Pass> &passes, const char *name = NULL);
   static bool equals(const vector<Pass> &A, const vector<Pass> &B);
@@ -57,7 +61,6 @@ class Film : public Node {
   NODE_DECLARE
 
   float exposure;
-  vector<Pass> passes;
   bool denoising_data_pass;
   bool denoising_clean_pass;
   bool denoising_prefiltered_pass;
@@ -88,6 +91,9 @@ class Film : public Node {
   Film();
   ~Film();
 
+  /* add default passes to scene */
+  static void add_default(Scene *scene);
+
   void device_update(Device *device, DeviceScene *dscene, Scene *scene);
   void device_free(Device *device, DeviceScene *dscene, Scene *scene);
 
@@ -95,7 +101,7 @@ class Film : public Node {
   void tag_passes_update(Scene *scene, const vector<Pass> &passes_, bool update_passes = true);
   void tag_update(Scene *scene);
 
-  int get_aov_offset(string name, bool &is_color);
+  int get_aov_offset(Scene *scene, string name, bool &is_color);
 };
 
 CCL_NAMESPACE_END
diff --git a/intern/cycles/render/integrator.cpp b/intern/cycles/render/integrator.cpp
index eff416efa2b..6c295b20538 100644
--- a/intern/cycles/render/integrator.cpp
+++ b/intern/cycles/render/integrator.cpp
@@ -152,7 +152,7 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
 
   kintegrator->seed = hash_uint2(seed, 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list