Nodes: Declare shader nodes in individual file namespace

To be used in the future to support unity builds
This commit is contained in:
2021-12-27 16:21:31 -05:00
parent 336f6f4bbd
commit d5b72fb06c
21 changed files with 231 additions and 221 deletions

View File

@@ -23,7 +23,7 @@
#include "node_shader_util.h" #include "node_shader_util.h"
namespace blender::nodes { namespace blender::nodes::node_shader_clamp_cc {
static void sh_node_clamp_declare(NodeDeclarationBuilder &b) static void sh_node_clamp_declare(NodeDeclarationBuilder &b)
{ {
@@ -34,8 +34,6 @@ static void sh_node_clamp_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Result")); b.add_output<decl::Float>(N_("Result"));
}; };
} // namespace blender::nodes
static void node_shader_init_clamp(bNodeTree *UNUSED(ntree), bNode *node) static void node_shader_init_clamp(bNodeTree *UNUSED(ntree), bNode *node)
{ {
node->custom1 = NODE_CLAMP_MINMAX; /* clamp type */ node->custom1 = NODE_CLAMP_MINMAX; /* clamp type */
@@ -75,15 +73,19 @@ static void sh_node_clamp_build_multi_function(blender::nodes::NodeMultiFunction
} }
} }
} // namespace blender::nodes::node_shader_clamp_cc
void register_node_type_sh_clamp() void register_node_type_sh_clamp()
{ {
namespace file_ns = blender::nodes::node_shader_clamp_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_CLAMP, "Clamp", NODE_CLASS_CONVERTER, 0); sh_fn_node_type_base(&ntype, SH_NODE_CLAMP, "Clamp", NODE_CLASS_CONVERTER, 0);
ntype.declare = blender::nodes::sh_node_clamp_declare; ntype.declare = file_ns::sh_node_clamp_declare;
node_type_init(&ntype, node_shader_init_clamp); node_type_init(&ntype, file_ns::node_shader_init_clamp);
node_type_gpu(&ntype, gpu_shader_clamp); node_type_gpu(&ntype, file_ns::gpu_shader_clamp);
ntype.build_multi_function = sh_node_clamp_build_multi_function; ntype.build_multi_function = file_ns::sh_node_clamp_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

View File

@@ -23,7 +23,7 @@
#include "node_shader_util.h" #include "node_shader_util.h"
namespace blender::nodes { namespace blender::nodes::node_shader_curves_cc {
static void sh_node_curve_vec_declare(NodeDeclarationBuilder &b) static void sh_node_curve_vec_declare(NodeDeclarationBuilder &b)
{ {
@@ -33,8 +33,6 @@ static void sh_node_curve_vec_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Vector>(N_("Vector")); b.add_output<decl::Vector>(N_("Vector"));
}; };
} // namespace blender::nodes
static void node_shader_exec_curve_vec(void *UNUSED(data), static void node_shader_exec_curve_vec(void *UNUSED(data),
int UNUSED(thread), int UNUSED(thread),
bNode *node, bNode *node,
@@ -152,25 +150,29 @@ static void sh_node_curve_vec_build_multi_function(
builder.construct_and_set_matching_fn<CurveVecFunction>(*cumap); builder.construct_and_set_matching_fn<CurveVecFunction>(*cumap);
} }
} // namespace blender::nodes::node_shader_curves_cc
void register_node_type_sh_curve_vec() void register_node_type_sh_curve_vec()
{ {
namespace file_ns = blender::nodes::node_shader_curves_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_CURVE_VEC, "Vector Curves", NODE_CLASS_OP_VECTOR, 0); sh_fn_node_type_base(&ntype, SH_NODE_CURVE_VEC, "Vector Curves", NODE_CLASS_OP_VECTOR, 0);
ntype.declare = blender::nodes::sh_node_curve_vec_declare; ntype.declare = file_ns::sh_node_curve_vec_declare;
node_type_init(&ntype, node_shader_init_curve_vec); node_type_init(&ntype, file_ns::node_shader_init_curve_vec);
node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_size_preset(&ntype, NODE_SIZE_LARGE);
node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves);
node_type_exec(&ntype, node_initexec_curves, nullptr, node_shader_exec_curve_vec); node_type_exec(&ntype, node_initexec_curves, nullptr, file_ns::node_shader_exec_curve_vec);
node_type_gpu(&ntype, gpu_shader_curve_vec); node_type_gpu(&ntype, file_ns::gpu_shader_curve_vec);
ntype.build_multi_function = sh_node_curve_vec_build_multi_function; ntype.build_multi_function = file_ns::sh_node_curve_vec_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }
/* **************** CURVE RGB ******************** */ /* **************** CURVE RGB ******************** */
namespace blender::nodes { namespace blender::nodes::node_shader_curves_cc {
static void sh_node_curve_rgb_declare(NodeDeclarationBuilder &b) static void sh_node_curve_rgb_declare(NodeDeclarationBuilder &b)
{ {
@@ -180,8 +182,6 @@ static void sh_node_curve_rgb_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Color")); b.add_output<decl::Color>(N_("Color"));
}; };
} // namespace blender::nodes
static void node_shader_exec_curve_rgb(void *UNUSED(data), static void node_shader_exec_curve_rgb(void *UNUSED(data),
int UNUSED(thread), int UNUSED(thread),
bNode *node, bNode *node,
@@ -329,25 +329,29 @@ static void sh_node_curve_rgb_build_multi_function(
builder.construct_and_set_matching_fn<CurveRGBFunction>(*cumap); builder.construct_and_set_matching_fn<CurveRGBFunction>(*cumap);
} }
} // namespace blender::nodes::node_shader_curves_cc
void register_node_type_sh_curve_rgb() void register_node_type_sh_curve_rgb()
{ {
namespace file_ns = blender::nodes::node_shader_curves_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR, 0); sh_fn_node_type_base(&ntype, SH_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR, 0);
ntype.declare = blender::nodes::sh_node_curve_rgb_declare; ntype.declare = file_ns::sh_node_curve_rgb_declare;
node_type_init(&ntype, node_shader_init_curve_rgb); node_type_init(&ntype, file_ns::node_shader_init_curve_rgb);
node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_size_preset(&ntype, NODE_SIZE_LARGE);
node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves);
node_type_exec(&ntype, node_initexec_curves, nullptr, node_shader_exec_curve_rgb); node_type_exec(&ntype, node_initexec_curves, nullptr, file_ns::node_shader_exec_curve_rgb);
node_type_gpu(&ntype, gpu_shader_curve_rgb); node_type_gpu(&ntype, file_ns::gpu_shader_curve_rgb);
ntype.build_multi_function = sh_node_curve_rgb_build_multi_function; ntype.build_multi_function = file_ns::sh_node_curve_rgb_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }
/* **************** CURVE FLOAT ******************** */ /* **************** CURVE FLOAT ******************** */
namespace blender::nodes { namespace blender::nodes::node_shader_curves_cc {
static void sh_node_curve_float_declare(NodeDeclarationBuilder &b) static void sh_node_curve_float_declare(NodeDeclarationBuilder &b)
{ {
@@ -361,8 +365,6 @@ static void sh_node_curve_float_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Value")); b.add_output<decl::Float>(N_("Value"));
}; };
} // namespace blender::nodes
static void node_shader_exec_curve_float(void *UNUSED(data), static void node_shader_exec_curve_float(void *UNUSED(data),
int UNUSED(thread), int UNUSED(thread),
bNode *node, bNode *node,
@@ -473,18 +475,22 @@ static void sh_node_curve_float_build_multi_function(
builder.construct_and_set_matching_fn<CurveFloatFunction>(*cumap); builder.construct_and_set_matching_fn<CurveFloatFunction>(*cumap);
} }
} // namespace blender::nodes::node_shader_curves_cc
void register_node_type_sh_curve_float() void register_node_type_sh_curve_float()
{ {
namespace file_ns = blender::nodes::node_shader_curves_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_CURVE_FLOAT, "Float Curve", NODE_CLASS_CONVERTER, 0); sh_fn_node_type_base(&ntype, SH_NODE_CURVE_FLOAT, "Float Curve", NODE_CLASS_CONVERTER, 0);
ntype.declare = blender::nodes::sh_node_curve_float_declare; ntype.declare = file_ns::sh_node_curve_float_declare;
node_type_init(&ntype, node_shader_init_curve_float); node_type_init(&ntype, file_ns::node_shader_init_curve_float);
node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_size_preset(&ntype, NODE_SIZE_LARGE);
node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves);
node_type_exec(&ntype, node_initexec_curves, nullptr, node_shader_exec_curve_float); node_type_exec(&ntype, node_initexec_curves, nullptr, file_ns::node_shader_exec_curve_float);
node_type_gpu(&ntype, gpu_shader_curve_float); node_type_gpu(&ntype, file_ns::gpu_shader_curve_float);
ntype.build_multi_function = sh_node_curve_float_build_multi_function; ntype.build_multi_function = file_ns::sh_node_curve_float_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

View File

@@ -31,7 +31,7 @@
NODE_STORAGE_FUNCS(NodeMapRange) NODE_STORAGE_FUNCS(NodeMapRange)
namespace blender::nodes { namespace blender::nodes::node_shader_map_range_cc {
static void sh_node_map_range_declare(NodeDeclarationBuilder &b) static void sh_node_map_range_declare(NodeDeclarationBuilder &b)
{ {
@@ -149,8 +149,6 @@ static void node_map_range_gather_link_searches(GatherLinkSearchOpParams &params
} }
} }
} // namespace blender::nodes
static const char *gpu_shader_get_name(int mode, bool use_vector) static const char *gpu_shader_get_name(int mode, bool use_vector)
{ {
if (use_vector) { if (use_vector) {
@@ -205,8 +203,6 @@ static int gpu_shader_map_range(GPUMaterial *mat,
return ret; return ret;
} }
namespace blender::nodes {
static inline float clamp_range(const float value, const float min, const float max) static inline float clamp_range(const float value, const float min, const float max)
{ {
return (min > max) ? std::clamp(value, max, min) : std::clamp(value, min, max); return (min > max) ? std::clamp(value, max, min) : std::clamp(value, min, max);
@@ -644,20 +640,22 @@ static void sh_node_map_range_build_multi_function(
} }
} }
} // namespace blender::nodes } // namespace blender::nodes::node_shader_map_range_cc
void register_node_type_sh_map_range() void register_node_type_sh_map_range()
{ {
namespace file_ns = blender::nodes::node_shader_map_range_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_MAP_RANGE, "Map Range", NODE_CLASS_CONVERTER, 0); sh_fn_node_type_base(&ntype, SH_NODE_MAP_RANGE, "Map Range", NODE_CLASS_CONVERTER, 0);
ntype.declare = blender::nodes::sh_node_map_range_declare; ntype.declare = file_ns::sh_node_map_range_declare;
node_type_init(&ntype, blender::nodes::node_shader_init_map_range); node_type_init(&ntype, file_ns::node_shader_init_map_range);
node_type_storage( node_type_storage(
&ntype, "NodeMapRange", node_free_standard_storage, node_copy_standard_storage); &ntype, "NodeMapRange", node_free_standard_storage, node_copy_standard_storage);
node_type_update(&ntype, blender::nodes::node_shader_update_map_range); node_type_update(&ntype, file_ns::node_shader_update_map_range);
node_type_gpu(&ntype, gpu_shader_map_range); node_type_gpu(&ntype, file_ns::gpu_shader_map_range);
ntype.build_multi_function = blender::nodes::sh_node_map_range_build_multi_function; ntype.build_multi_function = file_ns::sh_node_map_range_build_multi_function;
ntype.gather_link_search_ops = blender::nodes::node_map_range_gather_link_searches; ntype.gather_link_search_ops = file_ns::node_map_range_gather_link_searches;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

View File

@@ -28,7 +28,7 @@
/* **************** SCALAR MATH ******************** */ /* **************** SCALAR MATH ******************** */
namespace blender::nodes { namespace blender::nodes::node_shader_math_cc {
static void sh_node_math_declare(NodeDeclarationBuilder &b) static void sh_node_math_declare(NodeDeclarationBuilder &b)
{ {
@@ -57,8 +57,6 @@ static void sh_node_math_gather_link_searches(GatherLinkSearchOpParams &params)
} }
} }
} // namespace blender::nodes
static const char *gpu_shader_get_name(int mode) static const char *gpu_shader_get_name(int mode)
{ {
const blender::nodes::FloatMathOperationInfo *info = const blender::nodes::FloatMathOperationInfo *info =
@@ -174,17 +172,21 @@ static void sh_node_math_build_multi_function(blender::nodes::NodeMultiFunctionB
} }
} }
} // namespace blender::nodes::node_shader_math_cc
void register_node_type_sh_math() void register_node_type_sh_math()
{ {
namespace file_ns = blender::nodes::node_shader_math_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_MATH, "Math", NODE_CLASS_CONVERTER, 0); sh_fn_node_type_base(&ntype, SH_NODE_MATH, "Math", NODE_CLASS_CONVERTER, 0);
ntype.declare = blender::nodes::sh_node_math_declare; ntype.declare = file_ns::sh_node_math_declare;
ntype.labelfunc = node_math_label; ntype.labelfunc = node_math_label;
node_type_gpu(&ntype, gpu_shader_math); node_type_gpu(&ntype, file_ns::gpu_shader_math);
node_type_update(&ntype, node_math_update); node_type_update(&ntype, node_math_update);
ntype.build_multi_function = sh_node_math_build_multi_function; ntype.build_multi_function = file_ns::sh_node_math_build_multi_function;
ntype.gather_link_search_ops = blender::nodes::sh_node_math_gather_link_searches; ntype.gather_link_search_ops = file_ns::sh_node_math_gather_link_searches;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

View File

@@ -23,7 +23,7 @@
#include "node_shader_util.h" #include "node_shader_util.h"
namespace blender::nodes { namespace blender::nodes::node_shader_mix_rgb_cc {
static void sh_node_mix_rgb_declare(NodeDeclarationBuilder &b) static void sh_node_mix_rgb_declare(NodeDeclarationBuilder &b)
{ {
@@ -34,8 +34,6 @@ static void sh_node_mix_rgb_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Color")); b.add_output<decl::Color>(N_("Color"));
}; };
} // namespace blender::nodes
static void node_shader_exec_mix_rgb(void *UNUSED(data), static void node_shader_exec_mix_rgb(void *UNUSED(data),
int UNUSED(thread), int UNUSED(thread),
bNode *node, bNode *node,
@@ -183,16 +181,20 @@ static void sh_node_mix_rgb_build_multi_function(blender::nodes::NodeMultiFuncti
builder.construct_and_set_matching_fn<MixRGBFunction>(clamp, mix_type); builder.construct_and_set_matching_fn<MixRGBFunction>(clamp, mix_type);
} }
} // namespace blender::nodes::node_shader_mix_rgb_cc
void register_node_type_sh_mix_rgb() void register_node_type_sh_mix_rgb()
{ {
namespace file_ns = blender::nodes::node_shader_mix_rgb_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR, 0); sh_fn_node_type_base(&ntype, SH_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR, 0);
ntype.declare = blender::nodes::sh_node_mix_rgb_declare; ntype.declare = file_ns::sh_node_mix_rgb_declare;
ntype.labelfunc = node_blend_label; ntype.labelfunc = node_blend_label;
node_type_exec(&ntype, nullptr, nullptr, node_shader_exec_mix_rgb); node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_mix_rgb);
node_type_gpu(&ntype, gpu_shader_mix_rgb); node_type_gpu(&ntype, file_ns::gpu_shader_mix_rgb);
ntype.build_multi_function = sh_node_mix_rgb_build_multi_function; ntype.build_multi_function = file_ns::sh_node_mix_rgb_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

View File

@@ -29,7 +29,7 @@
#include "node_shader_util.h" #include "node_shader_util.h"
namespace blender::nodes { namespace blender::nodes::node_shader_rgb_to_bw_cc {
static void sh_node_valtorgb_declare(NodeDeclarationBuilder &b) static void sh_node_valtorgb_declare(NodeDeclarationBuilder &b)
{ {
@@ -39,8 +39,6 @@ static void sh_node_valtorgb_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Alpha")); b.add_output<decl::Float>(N_("Alpha"));
}; };
} // namespace blender::nodes
static void node_shader_exec_valtorgb(void *UNUSED(data), static void node_shader_exec_valtorgb(void *UNUSED(data),
int UNUSED(thread), int UNUSED(thread),
bNode *node, bNode *node,
@@ -172,23 +170,27 @@ static void sh_node_valtorgb_build_multi_function(
builder.construct_and_set_matching_fn<ColorBandFunction>(*color_band); builder.construct_and_set_matching_fn<ColorBandFunction>(*color_band);
} }
} // namespace blender::nodes::node_shader_rgb_to_bw_cc
void register_node_type_sh_valtorgb() void register_node_type_sh_valtorgb()
{ {
namespace file_ns = blender::nodes::node_shader_rgb_to_bw_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTER, 0); sh_fn_node_type_base(&ntype, SH_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTER, 0);
ntype.declare = blender::nodes::sh_node_valtorgb_declare; ntype.declare = file_ns::sh_node_valtorgb_declare;
node_type_init(&ntype, node_shader_init_valtorgb); node_type_init(&ntype, file_ns::node_shader_init_valtorgb);
node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_size_preset(&ntype, NODE_SIZE_LARGE);
node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage); node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage);
node_type_exec(&ntype, nullptr, nullptr, node_shader_exec_valtorgb); node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_valtorgb);
node_type_gpu(&ntype, gpu_shader_valtorgb); node_type_gpu(&ntype, file_ns::gpu_shader_valtorgb);
ntype.build_multi_function = sh_node_valtorgb_build_multi_function; ntype.build_multi_function = file_ns::sh_node_valtorgb_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }
namespace blender::nodes { namespace blender::nodes::node_shader_rgb_to_bw_cc {
static void sh_node_rgbtobw_declare(NodeDeclarationBuilder &b) static void sh_node_rgbtobw_declare(NodeDeclarationBuilder &b)
{ {
@@ -196,8 +198,6 @@ static void sh_node_rgbtobw_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Val")); b.add_output<decl::Float>(N_("Val"));
}; };
} // namespace blender::nodes
static void node_shader_exec_rgbtobw(void *UNUSED(data), static void node_shader_exec_rgbtobw(void *UNUSED(data),
int UNUSED(thread), int UNUSED(thread),
bNode *UNUSED(node), bNode *UNUSED(node),
@@ -222,14 +222,18 @@ static int gpu_shader_rgbtobw(GPUMaterial *mat,
return GPU_stack_link(mat, node, "rgbtobw", in, out); return GPU_stack_link(mat, node, "rgbtobw", in, out);
} }
} // namespace blender::nodes::node_shader_rgb_to_bw_cc
void register_node_type_sh_rgbtobw() void register_node_type_sh_rgbtobw()
{ {
namespace file_ns = blender::nodes::node_shader_rgb_to_bw_cc;
static bNodeType ntype; static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTER, 0); sh_node_type_base(&ntype, SH_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTER, 0);
ntype.declare = blender::nodes::sh_node_rgbtobw_declare; ntype.declare = file_ns::sh_node_rgbtobw_declare;
node_type_exec(&ntype, nullptr, nullptr, node_shader_exec_rgbtobw); node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_rgbtobw);
node_type_gpu(&ntype, gpu_shader_rgbtobw); node_type_gpu(&ntype, file_ns::gpu_shader_rgbtobw);
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

View File

@@ -23,7 +23,7 @@
#include "node_shader_util.h" #include "node_shader_util.h"
namespace blender::nodes { namespace blender::nodes::node_shader_sepcomb_rgb_cc {
static void sh_node_seprgb_declare(NodeDeclarationBuilder &b) static void sh_node_seprgb_declare(NodeDeclarationBuilder &b)
{ {
@@ -34,8 +34,6 @@ static void sh_node_seprgb_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("B")); b.add_output<decl::Float>(N_("B"));
}; };
} // namespace blender::nodes
static void node_shader_exec_seprgb(void *UNUSED(data), static void node_shader_exec_seprgb(void *UNUSED(data),
int UNUSED(thread), int UNUSED(thread),
bNode *UNUSED(node), bNode *UNUSED(node),
@@ -103,20 +101,24 @@ static void sh_node_seprgb_build_multi_function(blender::nodes::NodeMultiFunctio
builder.set_matching_fn(fn); builder.set_matching_fn(fn);
} }
} // namespace blender::nodes::node_shader_sepcomb_rgb_cc
void register_node_type_sh_seprgb() void register_node_type_sh_seprgb()
{ {
namespace file_ns = blender::nodes::node_shader_sepcomb_rgb_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_SEPRGB, "Separate RGB", NODE_CLASS_CONVERTER, 0); sh_fn_node_type_base(&ntype, SH_NODE_SEPRGB, "Separate RGB", NODE_CLASS_CONVERTER, 0);
ntype.declare = blender::nodes::sh_node_seprgb_declare; ntype.declare = file_ns::sh_node_seprgb_declare;
node_type_exec(&ntype, nullptr, nullptr, node_shader_exec_seprgb); node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_seprgb);
node_type_gpu(&ntype, gpu_shader_seprgb); node_type_gpu(&ntype, file_ns::gpu_shader_seprgb);
ntype.build_multi_function = sh_node_seprgb_build_multi_function; ntype.build_multi_function = file_ns::sh_node_seprgb_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }
namespace blender::nodes { namespace blender::nodes::node_shader_sepcomb_rgb_cc {
static void sh_node_combrgb_declare(NodeDeclarationBuilder &b) static void sh_node_combrgb_declare(NodeDeclarationBuilder &b)
{ {
@@ -127,8 +129,6 @@ static void sh_node_combrgb_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image")); b.add_output<decl::Color>(N_("Image"));
}; };
} // namespace blender::nodes
static void node_shader_exec_combrgb(void *UNUSED(data), static void node_shader_exec_combrgb(void *UNUSED(data),
int UNUSED(thread), int UNUSED(thread),
bNode *UNUSED(node), bNode *UNUSED(node),
@@ -163,15 +163,19 @@ static void sh_node_combrgb_build_multi_function(blender::nodes::NodeMultiFuncti
builder.set_matching_fn(fn); builder.set_matching_fn(fn);
} }
} // namespace blender::nodes::node_shader_sepcomb_rgb_cc
void register_node_type_sh_combrgb() void register_node_type_sh_combrgb()
{ {
namespace file_ns = blender::nodes::node_shader_sepcomb_rgb_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_COMBRGB, "Combine RGB", NODE_CLASS_CONVERTER, 0); sh_fn_node_type_base(&ntype, SH_NODE_COMBRGB, "Combine RGB", NODE_CLASS_CONVERTER, 0);
ntype.declare = blender::nodes::sh_node_combrgb_declare; ntype.declare = file_ns::sh_node_combrgb_declare;
node_type_exec(&ntype, nullptr, nullptr, node_shader_exec_combrgb); node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_combrgb);
node_type_gpu(&ntype, gpu_shader_combrgb); node_type_gpu(&ntype, file_ns::gpu_shader_combrgb);
ntype.build_multi_function = sh_node_combrgb_build_multi_function; ntype.build_multi_function = file_ns::sh_node_combrgb_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

View File

@@ -23,7 +23,7 @@
#include "node_shader_util.h" #include "node_shader_util.h"
namespace blender::nodes { namespace blender::nodes::node_shader_sepcomb_xyz_cc {
static void sh_node_sepxyz_declare(NodeDeclarationBuilder &b) static void sh_node_sepxyz_declare(NodeDeclarationBuilder &b)
{ {
@@ -34,8 +34,6 @@ static void sh_node_sepxyz_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Z")); b.add_output<decl::Float>(N_("Z"));
}; };
} // namespace blender::nodes
static int gpu_shader_sepxyz(GPUMaterial *mat, static int gpu_shader_sepxyz(GPUMaterial *mat,
bNode *node, bNode *node,
bNodeExecData *UNUSED(execdata), bNodeExecData *UNUSED(execdata),
@@ -88,19 +86,23 @@ static void sh_node_sepxyz_build_multi_function(blender::nodes::NodeMultiFunctio
builder.set_matching_fn(separate_fn); builder.set_matching_fn(separate_fn);
} }
} // namespace blender::nodes::node_shader_sepcomb_xyz_cc
void register_node_type_sh_sepxyz() void register_node_type_sh_sepxyz()
{ {
namespace file_ns = blender::nodes::node_shader_sepcomb_xyz_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_SEPXYZ, "Separate XYZ", NODE_CLASS_CONVERTER, 0); sh_fn_node_type_base(&ntype, SH_NODE_SEPXYZ, "Separate XYZ", NODE_CLASS_CONVERTER, 0);
ntype.declare = blender::nodes::sh_node_sepxyz_declare; ntype.declare = file_ns::sh_node_sepxyz_declare;
node_type_gpu(&ntype, gpu_shader_sepxyz); node_type_gpu(&ntype, file_ns::gpu_shader_sepxyz);
ntype.build_multi_function = sh_node_sepxyz_build_multi_function; ntype.build_multi_function = file_ns::sh_node_sepxyz_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }
namespace blender::nodes { namespace blender::nodes::node_shader_sepcomb_xyz_cc {
static void sh_node_combxyz_declare(NodeDeclarationBuilder &b) static void sh_node_combxyz_declare(NodeDeclarationBuilder &b)
{ {
@@ -111,8 +113,6 @@ static void sh_node_combxyz_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Vector>(N_("Vector")); b.add_output<decl::Vector>(N_("Vector"));
}; };
} // namespace blender::nodes
static int gpu_shader_combxyz(GPUMaterial *mat, static int gpu_shader_combxyz(GPUMaterial *mat,
bNode *node, bNode *node,
bNodeExecData *UNUSED(execdata), bNodeExecData *UNUSED(execdata),
@@ -129,14 +129,18 @@ static void sh_node_combxyz_build_multi_function(blender::nodes::NodeMultiFuncti
builder.set_matching_fn(fn); builder.set_matching_fn(fn);
} }
} // namespace blender::nodes::node_shader_sepcomb_xyz_cc
void register_node_type_sh_combxyz() void register_node_type_sh_combxyz()
{ {
namespace file_ns = blender::nodes::node_shader_sepcomb_xyz_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_COMBXYZ, "Combine XYZ", NODE_CLASS_CONVERTER, 0); sh_fn_node_type_base(&ntype, SH_NODE_COMBXYZ, "Combine XYZ", NODE_CLASS_CONVERTER, 0);
ntype.declare = blender::nodes::sh_node_combxyz_declare; ntype.declare = file_ns::sh_node_combxyz_declare;
node_type_gpu(&ntype, gpu_shader_combxyz); node_type_gpu(&ntype, file_ns::gpu_shader_combxyz);
ntype.build_multi_function = sh_node_combxyz_build_multi_function; ntype.build_multi_function = file_ns::sh_node_combxyz_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

View File

@@ -22,7 +22,7 @@
#include "BLI_float2.hh" #include "BLI_float2.hh"
#include "BLI_float4.hh" #include "BLI_float4.hh"
namespace blender::nodes { namespace blender::nodes::node_shader_tex_brick_cc {
static void sh_node_tex_brick_declare(NodeDeclarationBuilder &b) static void sh_node_tex_brick_declare(NodeDeclarationBuilder &b)
{ {
@@ -57,8 +57,6 @@ static void sh_node_tex_brick_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Fac")); b.add_output<decl::Float>(N_("Fac"));
}; };
} // namespace blender::nodes
static void node_shader_init_tex_brick(bNodeTree *UNUSED(ntree), bNode *node) static void node_shader_init_tex_brick(bNodeTree *UNUSED(ntree), bNode *node)
{ {
NodeTexBrick *tex = MEM_cnew<NodeTexBrick>(__func__); NodeTexBrick *tex = MEM_cnew<NodeTexBrick>(__func__);
@@ -101,8 +99,6 @@ static int node_shader_gpu_tex_brick(GPUMaterial *mat,
GPU_constant(&squash_freq)); GPU_constant(&squash_freq));
} }
namespace blender::nodes {
class BrickFunction : public fn::MultiFunction { class BrickFunction : public fn::MultiFunction {
private: private:
const float offset_; const float offset_;
@@ -266,20 +262,22 @@ static void sh_node_brick_build_multi_function(blender::nodes::NodeMultiFunction
tex->offset, tex->offset_freq, tex->squash, tex->squash_freq); tex->offset, tex->offset_freq, tex->squash, tex->squash_freq);
} }
} // namespace blender::nodes } // namespace blender::nodes::node_shader_tex_brick_cc
void register_node_type_sh_tex_brick() void register_node_type_sh_tex_brick()
{ {
namespace file_ns = blender::nodes::node_shader_tex_brick_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_TEX_BRICK, "Brick Texture", NODE_CLASS_TEXTURE, 0); sh_fn_node_type_base(&ntype, SH_NODE_TEX_BRICK, "Brick Texture", NODE_CLASS_TEXTURE, 0);
ntype.declare = blender::nodes::sh_node_tex_brick_declare; ntype.declare = file_ns::sh_node_tex_brick_declare;
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, node_shader_init_tex_brick); node_type_init(&ntype, file_ns::node_shader_init_tex_brick);
node_type_storage( node_type_storage(
&ntype, "NodeTexBrick", node_free_standard_storage, node_copy_standard_storage); &ntype, "NodeTexBrick", node_free_standard_storage, node_copy_standard_storage);
node_type_gpu(&ntype, node_shader_gpu_tex_brick); node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_brick);
ntype.build_multi_function = blender::nodes::sh_node_brick_build_multi_function; ntype.build_multi_function = file_ns::sh_node_brick_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

View File

@@ -19,7 +19,7 @@
#include "../node_shader_util.h" #include "../node_shader_util.h"
namespace blender::nodes { namespace blender::nodes::node_shader_tex_checker_cc {
static void sh_node_tex_checker_declare(NodeDeclarationBuilder &b) static void sh_node_tex_checker_declare(NodeDeclarationBuilder &b)
{ {
@@ -36,8 +36,6 @@ static void sh_node_tex_checker_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Fac")); b.add_output<decl::Float>(N_("Fac"));
}; };
} // namespace blender::nodes
static void node_shader_init_tex_checker(bNodeTree *UNUSED(ntree), bNode *node) static void node_shader_init_tex_checker(bNodeTree *UNUSED(ntree), bNode *node)
{ {
NodeTexChecker *tex = MEM_cnew<NodeTexChecker>(__func__); NodeTexChecker *tex = MEM_cnew<NodeTexChecker>(__func__);
@@ -59,8 +57,6 @@ static int node_shader_gpu_tex_checker(GPUMaterial *mat,
return GPU_stack_link(mat, node, "node_tex_checker", in, out); return GPU_stack_link(mat, node, "node_tex_checker", in, out);
} }
namespace blender::nodes {
class NodeTexChecker : public fn::MultiFunction { class NodeTexChecker : public fn::MultiFunction {
public: public:
NodeTexChecker() NodeTexChecker()
@@ -121,19 +117,21 @@ static void sh_node_tex_checker_build_multi_function(
builder.set_matching_fn(fn); builder.set_matching_fn(fn);
} }
} // namespace blender::nodes } // namespace blender::nodes::node_shader_tex_checker_cc
void register_node_type_sh_tex_checker() void register_node_type_sh_tex_checker()
{ {
namespace file_ns = blender::nodes::node_shader_tex_checker_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_TEX_CHECKER, "Checker Texture", NODE_CLASS_TEXTURE, 0); sh_fn_node_type_base(&ntype, SH_NODE_TEX_CHECKER, "Checker Texture", NODE_CLASS_TEXTURE, 0);
ntype.declare = blender::nodes::sh_node_tex_checker_declare; ntype.declare = file_ns::sh_node_tex_checker_declare;
node_type_init(&ntype, node_shader_init_tex_checker); node_type_init(&ntype, file_ns::node_shader_init_tex_checker);
node_type_storage( node_type_storage(
&ntype, "NodeTexChecker", node_free_standard_storage, node_copy_standard_storage); &ntype, "NodeTexChecker", node_free_standard_storage, node_copy_standard_storage);
node_type_gpu(&ntype, node_shader_gpu_tex_checker); node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_checker);
ntype.build_multi_function = blender::nodes::sh_node_tex_checker_build_multi_function; ntype.build_multi_function = file_ns::sh_node_tex_checker_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

View File

@@ -19,7 +19,7 @@
#include "../node_shader_util.h" #include "../node_shader_util.h"
namespace blender::nodes { namespace blender::nodes::node_shader_tex_gradient_cc {
static void sh_node_tex_gradient_declare(NodeDeclarationBuilder &b) static void sh_node_tex_gradient_declare(NodeDeclarationBuilder &b)
{ {
@@ -29,8 +29,6 @@ static void sh_node_tex_gradient_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Fac")).no_muted_links(); b.add_output<decl::Float>(N_("Fac")).no_muted_links();
}; };
} // namespace blender::nodes
static void node_shader_init_tex_gradient(bNodeTree *UNUSED(ntree), bNode *node) static void node_shader_init_tex_gradient(bNodeTree *UNUSED(ntree), bNode *node)
{ {
NodeTexGradient *tex = MEM_cnew<NodeTexGradient>(__func__); NodeTexGradient *tex = MEM_cnew<NodeTexGradient>(__func__);
@@ -55,8 +53,6 @@ static int node_shader_gpu_tex_gradient(GPUMaterial *mat,
return GPU_stack_link(mat, node, "node_tex_gradient", in, out, GPU_constant(&gradient_type)); return GPU_stack_link(mat, node, "node_tex_gradient", in, out, GPU_constant(&gradient_type));
} }
namespace blender::nodes {
class GradientFunction : public fn::MultiFunction { class GradientFunction : public fn::MultiFunction {
private: private:
int gradient_type_; int gradient_type_;
@@ -157,19 +153,21 @@ static void sh_node_gradient_tex_build_multi_function(
builder.construct_and_set_matching_fn<GradientFunction>(tex->gradient_type); builder.construct_and_set_matching_fn<GradientFunction>(tex->gradient_type);
} }
} // namespace blender::nodes } // namespace blender::nodes::node_shader_tex_gradient_cc
void register_node_type_sh_tex_gradient() void register_node_type_sh_tex_gradient()
{ {
namespace file_ns = blender::nodes::node_shader_tex_gradient_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_TEX_GRADIENT, "Gradient Texture", NODE_CLASS_TEXTURE, 0); sh_fn_node_type_base(&ntype, SH_NODE_TEX_GRADIENT, "Gradient Texture", NODE_CLASS_TEXTURE, 0);
ntype.declare = blender::nodes::sh_node_tex_gradient_declare; ntype.declare = file_ns::sh_node_tex_gradient_declare;
node_type_init(&ntype, node_shader_init_tex_gradient); node_type_init(&ntype, file_ns::node_shader_init_tex_gradient);
node_type_storage( node_type_storage(
&ntype, "NodeTexGradient", node_free_standard_storage, node_copy_standard_storage); &ntype, "NodeTexGradient", node_free_standard_storage, node_copy_standard_storage);
node_type_gpu(&ntype, node_shader_gpu_tex_gradient); node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_gradient);
ntype.build_multi_function = blender::nodes::sh_node_gradient_tex_build_multi_function; ntype.build_multi_function = file_ns::sh_node_gradient_tex_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

View File

@@ -19,7 +19,7 @@
#include "../node_shader_util.h" #include "../node_shader_util.h"
namespace blender::nodes { namespace blender::nodes::node_shader_tex_image_cc {
static void sh_node_tex_image_declare(NodeDeclarationBuilder &b) static void sh_node_tex_image_declare(NodeDeclarationBuilder &b)
{ {
@@ -29,8 +29,6 @@ static void sh_node_tex_image_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Alpha")).no_muted_links(); b.add_output<decl::Float>(N_("Alpha")).no_muted_links();
}; };
}; // namespace blender::nodes
static void node_shader_init_tex_image(bNodeTree *UNUSED(ntree), bNode *node) static void node_shader_init_tex_image(bNodeTree *UNUSED(ntree), bNode *node)
{ {
NodeTexImage *tex = MEM_cnew<NodeTexImage>(__func__); NodeTexImage *tex = MEM_cnew<NodeTexImage>(__func__);
@@ -173,17 +171,20 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat,
return true; return true;
} }
/* node type definition */ } // namespace blender::nodes::node_shader_tex_image_cc
void register_node_type_sh_tex_image() void register_node_type_sh_tex_image()
{ {
namespace file_ns = blender::nodes::node_shader_tex_image_cc;
static bNodeType ntype; static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_TEX_IMAGE, "Image Texture", NODE_CLASS_TEXTURE, 0); sh_node_type_base(&ntype, SH_NODE_TEX_IMAGE, "Image Texture", NODE_CLASS_TEXTURE, 0);
ntype.declare = blender::nodes::sh_node_tex_image_declare; ntype.declare = file_ns::sh_node_tex_image_declare;
node_type_init(&ntype, node_shader_init_tex_image); node_type_init(&ntype, file_ns::node_shader_init_tex_image);
node_type_storage( node_type_storage(
&ntype, "NodeTexImage", node_free_standard_storage, node_copy_standard_storage); &ntype, "NodeTexImage", node_free_standard_storage, node_copy_standard_storage);
node_type_gpu(&ntype, node_shader_gpu_tex_image); node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_image);
ntype.labelfunc = node_image_label; ntype.labelfunc = node_image_label;
node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_size_preset(&ntype, NODE_SIZE_LARGE);

View File

@@ -19,7 +19,7 @@
#include "../node_shader_util.h" #include "../node_shader_util.h"
namespace blender::nodes { namespace blender::nodes::node_shader_tex_magic_cc {
static void sh_node_tex_magic_declare(NodeDeclarationBuilder &b) static void sh_node_tex_magic_declare(NodeDeclarationBuilder &b)
{ {
@@ -31,8 +31,6 @@ static void sh_node_tex_magic_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Fac")).no_muted_links(); b.add_output<decl::Float>(N_("Fac")).no_muted_links();
}; };
} // namespace blender::nodes
static void node_shader_init_tex_magic(bNodeTree *UNUSED(ntree), bNode *node) static void node_shader_init_tex_magic(bNodeTree *UNUSED(ntree), bNode *node)
{ {
NodeTexMagic *tex = MEM_cnew<NodeTexMagic>(__func__); NodeTexMagic *tex = MEM_cnew<NodeTexMagic>(__func__);
@@ -58,8 +56,6 @@ static int node_shader_gpu_tex_magic(GPUMaterial *mat,
return GPU_stack_link(mat, node, "node_tex_magic", in, out, GPU_constant(&depth)); return GPU_stack_link(mat, node, "node_tex_magic", in, out, GPU_constant(&depth));
} }
namespace blender::nodes {
class MagicFunction : public fn::MultiFunction { class MagicFunction : public fn::MultiFunction {
private: private:
int depth_; int depth_;
@@ -179,19 +175,21 @@ static void sh_node_magic_tex_build_multi_function(
builder.construct_and_set_matching_fn<MagicFunction>(tex->depth); builder.construct_and_set_matching_fn<MagicFunction>(tex->depth);
} }
} // namespace blender::nodes } // namespace blender::nodes::node_shader_tex_magic_cc
void register_node_type_sh_tex_magic() void register_node_type_sh_tex_magic()
{ {
namespace file_ns = blender::nodes::node_shader_tex_magic_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_TEX_MAGIC, "Magic Texture", NODE_CLASS_TEXTURE, 0); sh_fn_node_type_base(&ntype, SH_NODE_TEX_MAGIC, "Magic Texture", NODE_CLASS_TEXTURE, 0);
ntype.declare = blender::nodes::sh_node_tex_magic_declare; ntype.declare = file_ns::sh_node_tex_magic_declare;
node_type_init(&ntype, node_shader_init_tex_magic); node_type_init(&ntype, file_ns::node_shader_init_tex_magic);
node_type_storage( node_type_storage(
&ntype, "NodeTexMagic", node_free_standard_storage, node_copy_standard_storage); &ntype, "NodeTexMagic", node_free_standard_storage, node_copy_standard_storage);
node_type_gpu(&ntype, node_shader_gpu_tex_magic); node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_magic);
ntype.build_multi_function = blender::nodes::sh_node_magic_tex_build_multi_function; ntype.build_multi_function = file_ns::sh_node_magic_tex_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

View File

@@ -23,7 +23,7 @@
NODE_STORAGE_FUNCS(NodeTexMusgrave) NODE_STORAGE_FUNCS(NodeTexMusgrave)
namespace blender::nodes { namespace blender::nodes::node_shader_musgrave_cc {
static void sh_node_tex_musgrave_declare(NodeDeclarationBuilder &b) static void sh_node_tex_musgrave_declare(NodeDeclarationBuilder &b)
{ {
@@ -42,8 +42,6 @@ static void sh_node_tex_musgrave_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Fac")).no_muted_links(); b.add_output<decl::Float>(N_("Fac")).no_muted_links();
}; };
} // namespace blender::nodes
static void node_shader_init_tex_musgrave(bNodeTree *UNUSED(ntree), bNode *node) static void node_shader_init_tex_musgrave(bNodeTree *UNUSED(ntree), bNode *node)
{ {
NodeTexMusgrave *tex = MEM_cnew<NodeTexMusgrave>(__func__); NodeTexMusgrave *tex = MEM_cnew<NodeTexMusgrave>(__func__);
@@ -132,8 +130,6 @@ static void node_shader_update_tex_musgrave(bNodeTree *ntree, bNode *node)
node_sock_label(outFacSock, "Height"); node_sock_label(outFacSock, "Height");
} }
namespace blender::nodes {
class MusgraveFunction : public fn::MultiFunction { class MusgraveFunction : public fn::MultiFunction {
private: private:
const int dimensions_; const int dimensions_;
@@ -523,7 +519,7 @@ class MusgraveFunction : public fn::MultiFunction {
} }
} }
} }
}; // namespace blender::nodes };
static void sh_node_musgrave_build_multi_function( static void sh_node_musgrave_build_multi_function(
blender::nodes::NodeMultiFunctionBuilder &builder) blender::nodes::NodeMultiFunctionBuilder &builder)
@@ -533,21 +529,23 @@ static void sh_node_musgrave_build_multi_function(
builder.construct_and_set_matching_fn<MusgraveFunction>(tex->dimensions, tex->musgrave_type); builder.construct_and_set_matching_fn<MusgraveFunction>(tex->dimensions, tex->musgrave_type);
} }
} // namespace blender::nodes } // namespace blender::nodes::node_shader_musgrave_cc
void register_node_type_sh_tex_musgrave() void register_node_type_sh_tex_musgrave()
{ {
namespace file_ns = blender::nodes::node_shader_musgrave_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_TEX_MUSGRAVE, "Musgrave Texture", NODE_CLASS_TEXTURE, 0); sh_fn_node_type_base(&ntype, SH_NODE_TEX_MUSGRAVE, "Musgrave Texture", NODE_CLASS_TEXTURE, 0);
ntype.declare = blender::nodes::sh_node_tex_musgrave_declare; ntype.declare = file_ns::sh_node_tex_musgrave_declare;
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, node_shader_init_tex_musgrave); node_type_init(&ntype, file_ns::node_shader_init_tex_musgrave);
node_type_storage( node_type_storage(
&ntype, "NodeTexMusgrave", node_free_standard_storage, node_copy_standard_storage); &ntype, "NodeTexMusgrave", node_free_standard_storage, node_copy_standard_storage);
node_type_gpu(&ntype, node_shader_gpu_tex_musgrave); node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_musgrave);
node_type_update(&ntype, node_shader_update_tex_musgrave); node_type_update(&ntype, file_ns::node_shader_update_tex_musgrave);
ntype.build_multi_function = blender::nodes::sh_node_musgrave_build_multi_function; ntype.build_multi_function = file_ns::sh_node_musgrave_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

View File

@@ -23,7 +23,7 @@
NODE_STORAGE_FUNCS(NodeTexNoise) NODE_STORAGE_FUNCS(NodeTexNoise)
namespace blender::nodes { namespace blender::nodes::node_shader_noise_cc {
static void sh_node_tex_noise_declare(NodeDeclarationBuilder &b) static void sh_node_tex_noise_declare(NodeDeclarationBuilder &b)
{ {
@@ -45,8 +45,6 @@ static void sh_node_tex_noise_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Color")).no_muted_links(); b.add_output<decl::Color>(N_("Color")).no_muted_links();
}; };
} // namespace blender::nodes
static void node_shader_init_tex_noise(bNodeTree *UNUSED(ntree), bNode *node) static void node_shader_init_tex_noise(bNodeTree *UNUSED(ntree), bNode *node)
{ {
NodeTexNoise *tex = MEM_cnew<NodeTexNoise>(__func__); NodeTexNoise *tex = MEM_cnew<NodeTexNoise>(__func__);
@@ -91,8 +89,6 @@ static void node_shader_update_tex_noise(bNodeTree *ntree, bNode *node)
nodeSetSocketAvailability(ntree, sockW, storage.dimensions == 1 || storage.dimensions == 4); nodeSetSocketAvailability(ntree, sockW, storage.dimensions == 1 || storage.dimensions == 4);
} }
namespace blender::nodes {
class NoiseFunction : public fn::MultiFunction { class NoiseFunction : public fn::MultiFunction {
private: private:
int dimensions_; int dimensions_;
@@ -250,21 +246,22 @@ static void sh_node_noise_build_multi_function(blender::nodes::NodeMultiFunction
builder.construct_and_set_matching_fn<NoiseFunction>(storage.dimensions); builder.construct_and_set_matching_fn<NoiseFunction>(storage.dimensions);
} }
} // namespace blender::nodes } // namespace blender::nodes::node_shader_noise_cc
/* node type definition */
void register_node_type_sh_tex_noise() void register_node_type_sh_tex_noise()
{ {
namespace file_ns = blender::nodes::node_shader_noise_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_TEX_NOISE, "Noise Texture", NODE_CLASS_TEXTURE, 0); sh_fn_node_type_base(&ntype, SH_NODE_TEX_NOISE, "Noise Texture", NODE_CLASS_TEXTURE, 0);
ntype.declare = blender::nodes::sh_node_tex_noise_declare; ntype.declare = file_ns::sh_node_tex_noise_declare;
node_type_init(&ntype, node_shader_init_tex_noise); node_type_init(&ntype, file_ns::node_shader_init_tex_noise);
node_type_storage( node_type_storage(
&ntype, "NodeTexNoise", node_free_standard_storage, node_copy_standard_storage); &ntype, "NodeTexNoise", node_free_standard_storage, node_copy_standard_storage);
node_type_gpu(&ntype, node_shader_gpu_tex_noise); node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_noise);
node_type_update(&ntype, node_shader_update_tex_noise); node_type_update(&ntype, file_ns::node_shader_update_tex_noise);
ntype.build_multi_function = blender::nodes::sh_node_noise_build_multi_function; ntype.build_multi_function = file_ns::sh_node_noise_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

View File

@@ -23,7 +23,7 @@
NODE_STORAGE_FUNCS(NodeTexVoronoi) NODE_STORAGE_FUNCS(NodeTexVoronoi)
namespace blender::nodes { namespace blender::nodes::node_shader_voronoi_cc {
static void sh_node_tex_voronoi_declare(NodeDeclarationBuilder &b) static void sh_node_tex_voronoi_declare(NodeDeclarationBuilder &b)
{ {
@@ -62,8 +62,6 @@ static void sh_node_tex_voronoi_declare(NodeDeclarationBuilder &b)
}); });
}; };
} // namespace blender::nodes
static void node_shader_init_tex_voronoi(bNodeTree *UNUSED(ntree), bNode *node) static void node_shader_init_tex_voronoi(bNodeTree *UNUSED(ntree), bNode *node)
{ {
NodeTexVoronoi *tex = MEM_cnew<NodeTexVoronoi>(__func__); NodeTexVoronoi *tex = MEM_cnew<NodeTexVoronoi>(__func__);
@@ -181,8 +179,6 @@ static void node_shader_update_tex_voronoi(bNodeTree *ntree, bNode *node)
nodeSetSocketAvailability(ntree, outRadiusSock, storage.feature == SHD_VORONOI_N_SPHERE_RADIUS); nodeSetSocketAvailability(ntree, outRadiusSock, storage.feature == SHD_VORONOI_N_SPHERE_RADIUS);
} }
namespace blender::nodes {
static MultiFunction::ExecutionHints voronoi_execution_hints{50, false}; static MultiFunction::ExecutionHints voronoi_execution_hints{50, false};
class VoronoiMinowskiFunction : public fn::MultiFunction { class VoronoiMinowskiFunction : public fn::MultiFunction {
@@ -1340,20 +1336,22 @@ static void sh_node_voronoi_build_multi_function(blender::nodes::NodeMultiFuncti
} }
} }
} // namespace blender::nodes } // namespace blender::nodes::node_shader_voronoi_cc
void register_node_type_sh_tex_voronoi() void register_node_type_sh_tex_voronoi()
{ {
namespace file_ns = blender::nodes::node_shader_voronoi_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_TEX_VORONOI, "Voronoi Texture", NODE_CLASS_TEXTURE, 0); sh_fn_node_type_base(&ntype, SH_NODE_TEX_VORONOI, "Voronoi Texture", NODE_CLASS_TEXTURE, 0);
ntype.declare = blender::nodes::sh_node_tex_voronoi_declare; ntype.declare = file_ns::sh_node_tex_voronoi_declare;
node_type_init(&ntype, node_shader_init_tex_voronoi); node_type_init(&ntype, file_ns::node_shader_init_tex_voronoi);
node_type_storage( node_type_storage(
&ntype, "NodeTexVoronoi", node_free_standard_storage, node_copy_standard_storage); &ntype, "NodeTexVoronoi", node_free_standard_storage, node_copy_standard_storage);
node_type_gpu(&ntype, node_shader_gpu_tex_voronoi); node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_voronoi);
node_type_update(&ntype, node_shader_update_tex_voronoi); node_type_update(&ntype, file_ns::node_shader_update_tex_voronoi);
ntype.build_multi_function = blender::nodes::sh_node_voronoi_build_multi_function; ntype.build_multi_function = file_ns::sh_node_voronoi_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

View File

@@ -21,7 +21,7 @@
#include "BLI_noise.hh" #include "BLI_noise.hh"
namespace blender::nodes { namespace blender::nodes::node_shader_wave_cc {
static void sh_node_tex_wave_declare(NodeDeclarationBuilder &b) static void sh_node_tex_wave_declare(NodeDeclarationBuilder &b)
{ {
@@ -41,8 +41,6 @@ static void sh_node_tex_wave_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Fac")).no_muted_links(); b.add_output<decl::Float>(N_("Fac")).no_muted_links();
}; };
} // namespace blender::nodes
static void node_shader_init_tex_wave(bNodeTree *UNUSED(ntree), bNode *node) static void node_shader_init_tex_wave(bNodeTree *UNUSED(ntree), bNode *node)
{ {
NodeTexWave *tex = MEM_cnew<NodeTexWave>(__func__); NodeTexWave *tex = MEM_cnew<NodeTexWave>(__func__);
@@ -81,8 +79,6 @@ static int node_shader_gpu_tex_wave(GPUMaterial *mat,
GPU_constant(&wave_profile)); GPU_constant(&wave_profile));
} }
namespace blender::nodes {
class WaveFunction : public fn::MultiFunction { class WaveFunction : public fn::MultiFunction {
private: private:
int wave_type_; int wave_type_;
@@ -216,19 +212,21 @@ static void sh_node_wave_tex_build_multi_function(
tex->wave_type, tex->bands_direction, tex->rings_direction, tex->wave_profile); tex->wave_type, tex->bands_direction, tex->rings_direction, tex->wave_profile);
} }
} // namespace blender::nodes } // namespace blender::nodes::node_shader_wave_cc
void register_node_type_sh_tex_wave() void register_node_type_sh_tex_wave()
{ {
namespace file_ns = blender::nodes::node_shader_wave_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_TEX_WAVE, "Wave Texture", NODE_CLASS_TEXTURE, 0); sh_fn_node_type_base(&ntype, SH_NODE_TEX_WAVE, "Wave Texture", NODE_CLASS_TEXTURE, 0);
ntype.declare = blender::nodes::sh_node_tex_wave_declare; ntype.declare = file_ns::sh_node_tex_wave_declare;
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, node_shader_init_tex_wave); node_type_init(&ntype, file_ns::node_shader_init_tex_wave);
node_type_storage(&ntype, "NodeTexWave", node_free_standard_storage, node_copy_standard_storage); node_type_storage(&ntype, "NodeTexWave", node_free_standard_storage, node_copy_standard_storage);
node_type_gpu(&ntype, node_shader_gpu_tex_wave); node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_wave);
ntype.build_multi_function = blender::nodes::sh_node_wave_tex_build_multi_function; ntype.build_multi_function = file_ns::sh_node_wave_tex_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

View File

@@ -21,7 +21,7 @@
#include "BLI_noise.hh" #include "BLI_noise.hh"
namespace blender::nodes { namespace blender::nodes::node_shader_white_noise_cc {
static void sh_node_tex_white_noise_declare(NodeDeclarationBuilder &b) static void sh_node_tex_white_noise_declare(NodeDeclarationBuilder &b)
{ {
@@ -35,8 +35,6 @@ static void sh_node_tex_white_noise_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Color")); b.add_output<decl::Color>(N_("Color"));
}; };
} // namespace blender::nodes
static void node_shader_init_tex_white_noise(bNodeTree *UNUSED(ntree), bNode *node) static void node_shader_init_tex_white_noise(bNodeTree *UNUSED(ntree), bNode *node)
{ {
node->custom1 = 3; node->custom1 = 3;
@@ -70,8 +68,6 @@ static void node_shader_update_tex_white_noise(bNodeTree *ntree, bNode *node)
nodeSetSocketAvailability(ntree, sockW, node->custom1 == 1 || node->custom1 == 4); nodeSetSocketAvailability(ntree, sockW, node->custom1 == 1 || node->custom1 == 4);
} }
namespace blender::nodes {
class WhiteNoiseFunction : public fn::MultiFunction { class WhiteNoiseFunction : public fn::MultiFunction {
private: private:
int dimensions_; int dimensions_;
@@ -192,19 +188,21 @@ static void sh_node_noise_build_multi_function(blender::nodes::NodeMultiFunction
builder.construct_and_set_matching_fn<WhiteNoiseFunction>((int)node.custom1); builder.construct_and_set_matching_fn<WhiteNoiseFunction>((int)node.custom1);
} }
} // namespace blender::nodes } // namespace blender::nodes::node_shader_white_noise_cc
void register_node_type_sh_tex_white_noise() void register_node_type_sh_tex_white_noise()
{ {
namespace file_ns = blender::nodes::node_shader_white_noise_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base( sh_fn_node_type_base(
&ntype, SH_NODE_TEX_WHITE_NOISE, "White Noise Texture", NODE_CLASS_TEXTURE, 0); &ntype, SH_NODE_TEX_WHITE_NOISE, "White Noise Texture", NODE_CLASS_TEXTURE, 0);
ntype.declare = blender::nodes::sh_node_tex_white_noise_declare; ntype.declare = file_ns::sh_node_tex_white_noise_declare;
node_type_init(&ntype, node_shader_init_tex_white_noise); node_type_init(&ntype, file_ns::node_shader_init_tex_white_noise);
node_type_gpu(&ntype, gpu_shader_tex_white_noise); node_type_gpu(&ntype, file_ns::gpu_shader_tex_white_noise);
node_type_update(&ntype, node_shader_update_tex_white_noise); node_type_update(&ntype, file_ns::node_shader_update_tex_white_noise);
ntype.build_multi_function = blender::nodes::sh_node_noise_build_multi_function; ntype.build_multi_function = file_ns::sh_node_noise_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

View File

@@ -23,15 +23,13 @@
#include "node_shader_util.h" #include "node_shader_util.h"
namespace blender::nodes { namespace blender::nodes::node_shader_value_cc {
static void sh_node_value_declare(NodeDeclarationBuilder &b) static void sh_node_value_declare(NodeDeclarationBuilder &b)
{ {
b.add_output<decl::Float>(N_("Value")); b.add_output<decl::Float>(N_("Value"));
}; };
} // namespace blender::nodes
static int gpu_shader_value(GPUMaterial *mat, static int gpu_shader_value(GPUMaterial *mat,
bNode *node, bNode *node,
bNodeExecData *UNUSED(execdata), bNodeExecData *UNUSED(execdata),
@@ -49,14 +47,18 @@ static void sh_node_value_build_multi_function(blender::nodes::NodeMultiFunction
builder.construct_and_set_matching_fn<blender::fn::CustomMF_Constant<float>>(value->value); builder.construct_and_set_matching_fn<blender::fn::CustomMF_Constant<float>>(value->value);
} }
} // namespace blender::nodes::node_shader_value_cc
void register_node_type_sh_value() void register_node_type_sh_value()
{ {
namespace file_ns = blender::nodes::node_shader_value_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_VALUE, "Value", NODE_CLASS_INPUT, 0); sh_fn_node_type_base(&ntype, SH_NODE_VALUE, "Value", NODE_CLASS_INPUT, 0);
ntype.declare = blender::nodes::sh_node_value_declare; ntype.declare = file_ns::sh_node_value_declare;
node_type_gpu(&ntype, gpu_shader_value); node_type_gpu(&ntype, file_ns::gpu_shader_value);
ntype.build_multi_function = sh_node_value_build_multi_function; ntype.build_multi_function = file_ns::sh_node_value_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

View File

@@ -26,7 +26,7 @@
#include "NOD_math_functions.hh" #include "NOD_math_functions.hh"
#include "NOD_socket_search_link.hh" #include "NOD_socket_search_link.hh"
namespace blender::nodes { namespace blender::nodes::node_shader_vector_math_cc {
static void sh_node_vector_math_declare(NodeDeclarationBuilder &b) static void sh_node_vector_math_declare(NodeDeclarationBuilder &b)
{ {
@@ -51,8 +51,6 @@ static void sh_node_vector_math_gather_link_searches(GatherLinkSearchOpParams &p
} }
} }
} // namespace blender::nodes
static const char *gpu_shader_get_name(int mode) static const char *gpu_shader_get_name(int mode)
{ {
switch (mode) { switch (mode) {
@@ -292,17 +290,21 @@ static void sh_node_vector_math_build_multi_function(
builder.set_matching_fn(fn); builder.set_matching_fn(fn);
} }
} // namespace blender::nodes::node_shader_vector_math_cc
void register_node_type_sh_vect_math() void register_node_type_sh_vect_math()
{ {
namespace file_ns = blender::nodes::node_shader_vector_math_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_VECTOR_MATH, "Vector Math", NODE_CLASS_OP_VECTOR, 0); sh_fn_node_type_base(&ntype, SH_NODE_VECTOR_MATH, "Vector Math", NODE_CLASS_OP_VECTOR, 0);
ntype.declare = blender::nodes::sh_node_vector_math_declare; ntype.declare = file_ns::sh_node_vector_math_declare;
ntype.labelfunc = node_vector_math_label; ntype.labelfunc = node_vector_math_label;
node_type_gpu(&ntype, gpu_shader_vector_math); node_type_gpu(&ntype, file_ns::gpu_shader_vector_math);
node_type_update(&ntype, node_shader_update_vector_math); node_type_update(&ntype, file_ns::node_shader_update_vector_math);
ntype.build_multi_function = sh_node_vector_math_build_multi_function; ntype.build_multi_function = file_ns::sh_node_vector_math_build_multi_function;
ntype.gather_link_search_ops = blender::nodes::sh_node_vector_math_gather_link_searches; ntype.gather_link_search_ops = file_ns::sh_node_vector_math_gather_link_searches;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

View File

@@ -23,7 +23,7 @@
#include "../node_shader_util.h" #include "../node_shader_util.h"
namespace blender::nodes { namespace blender::nodes::node_shader_vector_rotate_cc {
static void sh_node_vector_rotate_declare(NodeDeclarationBuilder &b) static void sh_node_vector_rotate_declare(NodeDeclarationBuilder &b)
{ {
@@ -36,8 +36,6 @@ static void sh_node_vector_rotate_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Vector>(N_("Vector")); b.add_output<decl::Vector>(N_("Vector"));
}; };
} // namespace blender::nodes
static const char *gpu_shader_get_name(int mode) static const char *gpu_shader_get_name(int mode)
{ {
switch (mode) { switch (mode) {
@@ -205,15 +203,19 @@ static void node_shader_update_vector_rotate(bNodeTree *ntree, bNode *node)
ntree, sock_angle, !ELEM(node->custom1, NODE_VECTOR_ROTATE_TYPE_EULER_XYZ)); ntree, sock_angle, !ELEM(node->custom1, NODE_VECTOR_ROTATE_TYPE_EULER_XYZ));
} }
} // namespace blender::nodes::node_shader_vector_rotate_cc
void register_node_type_sh_vector_rotate() void register_node_type_sh_vector_rotate()
{ {
namespace file_ns = blender::nodes::node_shader_vector_rotate_cc;
static bNodeType ntype; static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_VECTOR_ROTATE, "Vector Rotate", NODE_CLASS_OP_VECTOR, 0); sh_fn_node_type_base(&ntype, SH_NODE_VECTOR_ROTATE, "Vector Rotate", NODE_CLASS_OP_VECTOR, 0);
ntype.declare = blender::nodes::sh_node_vector_rotate_declare; ntype.declare = file_ns::sh_node_vector_rotate_declare;
node_type_gpu(&ntype, gpu_shader_vector_rotate); node_type_gpu(&ntype, file_ns::gpu_shader_vector_rotate);
node_type_update(&ntype, node_shader_update_vector_rotate); node_type_update(&ntype, file_ns::node_shader_update_vector_rotate);
ntype.build_multi_function = sh_node_vector_rotate_build_multi_function; ntype.build_multi_function = file_ns::sh_node_vector_rotate_build_multi_function;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }