diff options
author | Hans Goudey <h.goudey@me.com> | 2021-09-23 01:34:09 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-09-23 01:34:09 +0300 |
commit | 79bcc19240258fe697b583376f59902c3235691c (patch) | |
tree | ebb15ffda6a3381435551924ae6dadeca1bd80d3 /source/blender/nodes/shader/nodes/node_shader_tex_noise.cc | |
parent | 6fb4c8f040f87bed4d6c69e3a718114eef91b7e1 (diff) |
Cleanup: Move more shader nodes to socket declaration API
I had to add `no_muted_links` to the declaration API. The name could
change there, but I think it's more obvious than "internal"
Diffstat (limited to 'source/blender/nodes/shader/nodes/node_shader_tex_noise.cc')
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_tex_noise.cc | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc b/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc index c0deb232b2d..1ae6b3a616c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc @@ -21,32 +21,25 @@ #include "BLI_noise.hh" -/* **************** NOISE ******************** */ +namespace blender::nodes { -static bNodeSocketTemplate sh_node_tex_noise_in[] = { - {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {SOCK_FLOAT, N_("W"), 0.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, - {SOCK_FLOAT, N_("Scale"), 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, - {SOCK_FLOAT, N_("Detail"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 16.0f}, - {SOCK_FLOAT, N_("Roughness"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Distortion"), 0.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, - {-1, ""}, +static void sh_node_tex_noise_declare(NodeDeclarationBuilder &b) +{ + b.add_input<decl::Vector>("Vector").hide_value(); + b.add_input<decl::Float>("W").min(-1000.0f).max(1000.0f); + b.add_input<decl::Float>("Scale").min(-1000.0f).max(1000.0f).default_value(5.0f); + b.add_input<decl::Float>("Detail").min(0.0f).max(16.0f).default_value(2.0f); + b.add_input<decl::Float>("Roughness") + .min(0.0f) + .max(1.0f) + .default_value(0.5f) + .subtype(PROP_FACTOR); + b.add_input<decl::Float>("Distortion").min(-1000.0f).max(1000.0f).default_value(0.0f); + b.add_output<decl::Float>("Fac").no_muted_links(); + b.add_output<decl::Color>("Color").no_muted_links(); }; -static bNodeSocketTemplate sh_node_tex_noise_out[] = { - {SOCK_FLOAT, - N_("Fac"), - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 1.0f, - PROP_FACTOR, - SOCK_NO_INTERNAL_LINK}, - {SOCK_RGBA, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_NO_INTERNAL_LINK}, - {-1, ""}, -}; +} // namespace blender::nodes static void node_shader_init_tex_noise(bNodeTree *UNUSED(ntree), bNode *node) { @@ -252,7 +245,7 @@ void register_node_type_sh_tex_noise(void) static bNodeType ntype; sh_fn_node_type_base(&ntype, SH_NODE_TEX_NOISE, "Noise Texture", NODE_CLASS_TEXTURE, 0); - node_type_socket_templates(&ntype, sh_node_tex_noise_in, sh_node_tex_noise_out); + ntype.declare = blender::nodes::sh_node_tex_noise_declare; node_type_init(&ntype, node_shader_init_tex_noise); node_type_storage( &ntype, "NodeTexNoise", node_free_standard_storage, node_copy_standard_storage); |