[Bf-blender-cvs] [f60b95b5320] master: Shader Nodes: Split each node into own file

Aaron Carlisle noreply at git.blender.org
Mon Dec 6 20:47:54 CET 2021


Commit: f60b95b5320f8d6abe6a629fe8fc4f1b94d0d91c
Author: Aaron Carlisle
Date:   Mon Dec 6 14:47:11 2021 -0500
Branches: master
https://developer.blender.org/rBf60b95b5320f8d6abe6a629fe8fc4f1b94d0d91c

Shader Nodes: Split each node into own file

This improves both code finding,  for example "color ramp" now has its own file.
And now each node has its own namespace so function names can be simplified
similar to rBfab39440e94

This commit also makes all file names use snake case instead of camel case.

Reviewed By: HooglyBoogly

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

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

M	source/blender/blenkernel/intern/node.cc
M	source/blender/nodes/NOD_shader.h
M	source/blender/nodes/shader/CMakeLists.txt
R065	source/blender/nodes/shader/nodes/node_shader_valToRgb.cc	source/blender/nodes/shader/nodes/node_shader_color_ramp.cc
R058	source/blender/nodes/shader/nodes/node_shader_sepcombHSV.cc	source/blender/nodes/shader/nodes/node_shader_combine_hsv.cc
A	source/blender/nodes/shader/nodes/node_shader_combine_rgb.cc
A	source/blender/nodes/shader/nodes/node_shader_combine_xyz.cc
R097	source/blender/nodes/shader/nodes/node_shader_mixRgb.cc	source/blender/nodes/shader/nodes/node_shader_mix_rgb.cc
A	source/blender/nodes/shader/nodes/node_shader_rgb_to_bw.cc
A	source/blender/nodes/shader/nodes/node_shader_separate_hsv.cc
R062	source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc	source/blender/nodes/shader/nodes/node_shader_separate_rgb.cc
R065	source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.cc	source/blender/nodes/shader/nodes/node_shader_separate_xyz.cc
R092	source/blender/nodes/shader/nodes/node_shader_shaderToRgb.cc	source/blender/nodes/shader/nodes/node_shader_shader_to_rgb.cc
R087	source/blender/nodes/shader/nodes/node_shader_uvAlongStroke.cc	source/blender/nodes/shader/nodes/node_shader_uv_along_stroke.cc
R096	source/blender/nodes/shader/nodes/node_shader_vectTransform.cc	source/blender/nodes/shader/nodes/node_shader_vector_transform.cc

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

diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index 6558ad894b8..a4f28c103a7 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -5686,7 +5686,7 @@ static void registerShaderNodes()
   register_node_type_sh_wavelength();
   register_node_type_sh_blackbody();
   register_node_type_sh_mix_rgb();
-  register_node_type_sh_valtorgb();
+  register_node_type_sh_color_ramp();
   register_node_type_sh_rgbtobw();
   register_node_type_sh_shadertorgb();
   register_node_type_sh_normal();
diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h
index 76c174201e8..74933e69ab2 100644
--- a/source/blender/nodes/NOD_shader.h
+++ b/source/blender/nodes/NOD_shader.h
@@ -42,7 +42,7 @@ void register_node_type_sh_camera(void);
 void register_node_type_sh_value(void);
 void register_node_type_sh_rgb(void);
 void register_node_type_sh_mix_rgb(void);
-void register_node_type_sh_valtorgb(void);
+void register_node_type_sh_color_ramp(void);
 void register_node_type_sh_rgbtobw(void);
 void register_node_type_sh_shadertorgb(void);
 void register_node_type_sh_normal(void);
diff --git a/source/blender/nodes/shader/CMakeLists.txt b/source/blender/nodes/shader/CMakeLists.txt
index b582960f03f..bdbdef6e9ec 100644
--- a/source/blender/nodes/shader/CMakeLists.txt
+++ b/source/blender/nodes/shader/CMakeLists.txt
@@ -59,6 +59,10 @@ set(SRC
   nodes/node_shader_bump.cc
   nodes/node_shader_camera.cc
   nodes/node_shader_clamp.cc
+  nodes/node_shader_color_ramp.cc
+  nodes/node_shader_combine_hsv.cc
+  nodes/node_shader_combine_rgb.cc
+  nodes/node_shader_combine_xyz.cc
   nodes/node_shader_common.cc
   nodes/node_shader_curves.cc
   nodes/node_shader_displacement.cc
@@ -78,7 +82,7 @@ set(SRC
   nodes/node_shader_map_range.cc
   nodes/node_shader_mapping.cc
   nodes/node_shader_math.cc
-  nodes/node_shader_mixRgb.cc
+  nodes/node_shader_mix_rgb.cc
   nodes/node_shader_mix_shader.cc
   nodes/node_shader_normal.cc
   nodes/node_shader_normal_map.cc
@@ -90,11 +94,12 @@ set(SRC
   nodes/node_shader_output_world.cc
   nodes/node_shader_particle_info.cc
   nodes/node_shader_rgb.cc
+  nodes/node_shader_rgb_to_bw.cc
   nodes/node_shader_script.cc
-  nodes/node_shader_sepcombHSV.cc
-  nodes/node_shader_sepcombRGB.cc
-  nodes/node_shader_sepcombXYZ.cc
-  nodes/node_shader_shaderToRgb.cc
+  nodes/node_shader_separate_hsv.cc
+  nodes/node_shader_separate_rgb.cc
+  nodes/node_shader_separate_xyz.cc
+  nodes/node_shader_shader_to_rgb.cc
   nodes/node_shader_squeeze.cc
   nodes/node_shader_subsurface_scattering.cc
   nodes/node_shader_tangent.cc
@@ -112,14 +117,13 @@ set(SRC
   nodes/node_shader_tex_voronoi.cc
   nodes/node_shader_tex_wave.cc
   nodes/node_shader_tex_white_noise.cc
-  nodes/node_shader_uvAlongStroke.cc
+  nodes/node_shader_uv_along_stroke.cc
   nodes/node_shader_uvmap.cc
-  nodes/node_shader_valToRgb.cc
   nodes/node_shader_value.cc
-  nodes/node_shader_vectTransform.cc
   nodes/node_shader_vector_displacement.cc
   nodes/node_shader_vector_math.cc
   nodes/node_shader_vector_rotate.cc
+  nodes/node_shader_vector_transform.cc
   nodes/node_shader_vertex_color.cc
   nodes/node_shader_volume_absorption.cc
   nodes/node_shader_volume_info.cc
diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc b/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc
similarity index 65%
rename from source/blender/nodes/shader/nodes/node_shader_valToRgb.cc
rename to source/blender/nodes/shader/nodes/node_shader_color_ramp.cc
index b65269f8e35..2bb3f2e08cf 100644
--- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc
@@ -13,7 +13,7 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * The Original Code is Copyright (C) 2021 Blender Foundation.
  * All rights reserved.
  */
 
@@ -21,17 +21,15 @@
  * \ingroup shdnodes
  */
 
-#include "IMB_colormanagement.h"
-
 #include "DNA_texture_types.h"
 
 #include "BLI_color.hh"
 
 #include "node_shader_util.hh"
 
-namespace blender::nodes::node_shader_valToRgb_cc {
+namespace blender::nodes::node_shader_color_ramp_cc {
 
-static void sh_node_valtorgb_declare(NodeDeclarationBuilder &b)
+static void sh_node_color_ramp_declare(NodeDeclarationBuilder &b)
 {
   b.is_function_node();
   b.add_input<decl::Float>(N_("Fac")).default_value(0.5f).min(0.0f).max(1.0f).subtype(PROP_FACTOR);
@@ -39,12 +37,12 @@ static void sh_node_valtorgb_declare(NodeDeclarationBuilder &b)
   b.add_output<decl::Float>(N_("Alpha"));
 };
 
-static void node_shader_exec_valtorgb(void *UNUSED(data),
-                                      int UNUSED(thread),
-                                      bNode *node,
-                                      bNodeExecData *UNUSED(execdata),
-                                      bNodeStack **in,
-                                      bNodeStack **out)
+static void node_shader_exec_color_ramp(void *UNUSED(data),
+                                        int UNUSED(thread),
+                                        bNode *node,
+                                        bNodeExecData *UNUSED(execdata),
+                                        bNodeStack **in,
+                                        bNodeStack **out)
 {
   /* stack order in: fac */
   /* stack order out: col, alpha */
@@ -58,16 +56,16 @@ static void node_shader_exec_valtorgb(void *UNUSED(data),
   }
 }
 
-static void node_shader_init_valtorgb(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_shader_init_color_ramp(bNodeTree *UNUSED(ntree), bNode *node)
 {
   node->storage = BKE_colorband_add(true);
 }
 
-static int gpu_shader_valtorgb(GPUMaterial *mat,
-                               bNode *node,
-                               bNodeExecData *UNUSED(execdata),
-                               GPUNodeStack *in,
-                               GPUNodeStack *out)
+static int gpu_shader_color_ramp(GPUMaterial *mat,
+                                 bNode *node,
+                                 bNodeExecData *UNUSED(execdata),
+                                 GPUNodeStack *in,
+                                 GPUNodeStack *out)
 {
   struct ColorBand *coba = (ColorBand *)node->storage;
   float *array, layer;
@@ -162,7 +160,7 @@ class ColorBandFunction : public blender::fn::MultiFunction {
   }
 };
 
-static void sh_node_valtorgb_build_multi_function(
+static void sh_node_color_ramp_build_multi_function(
     blender::nodes::NodeMultiFunctionBuilder &builder)
 {
   bNode &bnode = builder.node();
@@ -170,66 +168,22 @@ static void sh_node_valtorgb_build_multi_function(
   builder.construct_and_set_matching_fn<ColorBandFunction>(*color_band);
 }
 
-static void sh_node_rgbtobw_declare(NodeDeclarationBuilder &b)
-{
-  b.add_input<decl::Color>(N_("Color")).default_value({0.5f, 0.5f, 0.5f, 1.0f});
-  b.add_output<decl::Float>(N_("Val"));
-};
-
-static void node_shader_exec_rgbtobw(void *UNUSED(data),
-                                     int UNUSED(thread),
-                                     bNode *UNUSED(node),
-                                     bNodeExecData *UNUSED(execdata),
-                                     bNodeStack **in,
-                                     bNodeStack **out)
-{
-  /* Stack order out: BW. */
-  /* Stack order in: COL. */
-  float col[3];
-  nodestack_get_vec(col, SOCK_VECTOR, in[0]);
-
-  out[0]->vec[0] = IMB_colormanagement_get_luminance(col);
-}
-
-static int gpu_shader_rgbtobw(GPUMaterial *mat,
-                              bNode *node,
-                              bNodeExecData *UNUSED(execdata),
-                              GPUNodeStack *in,
-                              GPUNodeStack *out)
-{
-  return GPU_stack_link(mat, node, "rgbtobw", in, out);
-}
-
-}  // namespace blender::nodes::node_shader_valToRgb_cc
+}  // namespace blender::nodes::node_shader_color_ramp_cc
 
-void register_node_type_sh_valtorgb()
+void register_node_type_sh_color_ramp()
 {
-  namespace file_ns = blender::nodes::node_shader_valToRgb_cc;
+  namespace file_ns = blender::nodes::node_shader_color_ramp_cc;
 
   static bNodeType ntype;
 
   sh_fn_node_type_base(&ntype, SH_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTER, 0);
-  ntype.declare = file_ns::sh_node_valtorgb_declare;
-  node_type_init(&ntype, file_ns::node_shader_init_valtorgb);
+  ntype.declare = file_ns::sh_node_color_ramp_declare;
+  node_type_init(&ntype, file_ns::node_shader_init_color_ramp);
   node_type_size_preset(&ntype, NODE_SIZE_LARGE);
   node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage);
-  node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_valtorgb);
-  node_type_gpu(&ntype, file_ns::gpu_shader_valtorgb);
-  ntype.build_multi_function = file_ns::sh_node_valtorgb_build_multi_function;
-
-  nodeRegisterType(&ntype);
-}
-
-void register_node_type_sh_rgbtobw()
-{
-  namespace file_ns = blender::nodes::node_shader_valToRgb_cc;
-
-  static bNodeType ntype;
-
-  sh_node_type_base(&ntype, SH_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTER, 0);
-  ntype.declare = file_ns::sh_node_rgbtobw_declare;
-  node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_rgbtobw);
-  node_type_gpu(&ntype, file_ns::gpu_shader_rgbtobw);
+  node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_color_ramp);
+  node_type_gpu(&ntype, file_ns::gpu_shader_color_ramp);
+  ntype.build_multi_function = file_ns::sh_node_color_ramp_build_multi_function;
 
   nodeRegisterType(&ntype);
-}
+}
\ No newline at end of file
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.cc b/source/blender/nodes/shader/nodes/node_shader_combine_hsv.cc
similarity index 58%
copy from source/blender/nodes/shader/nodes/node_shader_sepcombHSV.cc
copy to source/blender/nodes/shader/nodes/node_shader_combine_hsv.cc
index b47c98fadec..4d4879fd060 100644
--- a/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_combine_hsv.cc
@@ -

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list