From ed9b21098dd27bf9364397357f89b4c2648f40c2 Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Thu, 6 Jan 2022 17:57:18 -0500 Subject: Cleanup: Use new socket builder API This commit converts most shader or bsdf nodes. --- .../shader/nodes/node_shader_bsdf_anisotropic.cc | 37 ++--- .../nodes/shader/nodes/node_shader_bsdf_diffuse.cc | 27 ++-- .../nodes/shader/nodes/node_shader_bsdf_glass.cc | 29 ++-- .../nodes/shader/nodes/node_shader_bsdf_glossy.cc | 27 ++-- .../nodes/shader/nodes/node_shader_bsdf_hair.cc | 39 +++--- .../nodes/node_shader_bsdf_hair_principled.cc | 87 +++++++----- .../shader/nodes/node_shader_bsdf_principled.cc | 153 +++++++++++++-------- .../shader/nodes/node_shader_bsdf_refraction.cc | 29 ++-- .../nodes/shader/nodes/node_shader_bsdf_toon.cc | 33 ++--- .../shader/nodes/node_shader_bsdf_translucent.cc | 21 +-- .../shader/nodes/node_shader_bsdf_transparent.cc | 19 +-- .../nodes/shader/nodes/node_shader_bsdf_velvet.cc | 27 ++-- .../shader/nodes/node_shader_eevee_specular.cc | 71 +++++----- .../nodes/shader/nodes/node_shader_emission.cc | 20 +-- .../nodes/node_shader_subsurface_scattering.cc | 39 +++--- .../shader/nodes/node_shader_volume_absorption.cc | 21 +-- .../shader/nodes/node_shader_volume_principled.cc | 49 +++---- 17 files changed, 375 insertions(+), 353 deletions(-) (limited to 'source/blender/nodes/shader') diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc index 2e698aeb4d7..9529edbad0e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc @@ -21,22 +21,24 @@ namespace blender::nodes::node_shader_bsdf_anisotropic_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_bsdf_anisotropic_in[] = { - {SOCK_RGBA, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Roughness"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Anisotropy"), 0.5f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f}, - {SOCK_FLOAT, N_("Rotation"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {SOCK_VECTOR, N_("Tangent"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_bsdf_anisotropic_out[] = { - {SOCK_SHADER, N_("BSDF")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input(N_("Roughness")) + .default_value(0.5f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Anisotropy")).default_value(0.5f).min(-1.0f).max(1.0f); + b.add_input(N_("Rotation")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Normal")).hide_value(); + b.add_input(N_("Tangent")).hide_value(); + b.add_output(N_("BSDF")); +} static void node_shader_init_anisotropic(bNodeTree *UNUSED(ntree), bNode *node) { @@ -76,8 +78,7 @@ void register_node_type_sh_bsdf_anisotropic() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_ANISOTROPIC, "Anisotropic BSDF", NODE_CLASS_SHADER); - node_type_socket_templates( - &ntype, file_ns::sh_node_bsdf_anisotropic_in, file_ns::sh_node_bsdf_anisotropic_out); + ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, file_ns::node_shader_init_anisotropic); node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_anisotropic); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.cc index 3719227f46c..5848ca76cdd 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.cc @@ -21,19 +21,17 @@ namespace blender::nodes::node_shader_bsdf_diffuse_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_bsdf_diffuse_in[] = { - {SOCK_RGBA, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_bsdf_diffuse_out[] = { - {SOCK_SHADER, N_("BSDF")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input(N_("Roughness")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Normal")).hide_value(); + b.add_output(N_("BSDF")); +} static int node_shader_gpu_bsdf_diffuse(GPUMaterial *mat, bNode *node, @@ -60,8 +58,7 @@ void register_node_type_sh_bsdf_diffuse() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_DIFFUSE, "Diffuse BSDF", NODE_CLASS_SHADER); - node_type_socket_templates( - &ntype, file_ns::sh_node_bsdf_diffuse_in, file_ns::sh_node_bsdf_diffuse_out); + ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_diffuse); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.cc index 2cea42146fd..47d4b87198b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.cc @@ -21,20 +21,18 @@ namespace blender::nodes::node_shader_bsdf_glass_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_bsdf_glass_in[] = { - {SOCK_RGBA, N_("Color"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("IOR"), 1.45f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_bsdf_glass_out[] = { - {SOCK_SHADER, N_("BSDF")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Color")).default_value({1.0f, 1.0f, 1.0f, 1.0f}); + b.add_input(N_("Roughness")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("IOR")).default_value(1.45f).min(0.0f).max(1000.0f); + b.add_input(N_("Normal")).hide_value(); + b.add_output(N_("BSDF")); +} static void node_shader_init_glass(bNodeTree *UNUSED(ntree), bNode *node) { @@ -78,8 +76,7 @@ void register_node_type_sh_bsdf_glass() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_GLASS, "Glass BSDF", NODE_CLASS_SHADER); - node_type_socket_templates( - &ntype, file_ns::sh_node_bsdf_glass_in, file_ns::sh_node_bsdf_glass_out); + ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, file_ns::node_shader_init_glass); node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_glass); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.cc index 1227d79af93..03a3e634f56 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.cc @@ -21,19 +21,17 @@ namespace blender::nodes::node_shader_bsdf_glossy_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_bsdf_glossy_in[] = { - {SOCK_RGBA, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Roughness"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_bsdf_glossy_out[] = { - {SOCK_SHADER, N_("BSDF")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input(N_("Roughness")) + .default_value(0.5f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Normal")).hide_value(); + b.add_output(N_("BSDF")); +} static void node_shader_init_glossy(bNodeTree *UNUSED(ntree), bNode *node) { @@ -77,8 +75,7 @@ void register_node_type_sh_bsdf_glossy() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_GLOSSY, "Glossy BSDF", NODE_CLASS_SHADER); - node_type_socket_templates( - &ntype, file_ns::sh_node_bsdf_glossy_in, file_ns::sh_node_bsdf_glossy_out); + ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, file_ns::node_shader_init_glossy); node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_glossy); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc index 56282d1c991..e3de937367d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc @@ -21,21 +21,27 @@ namespace blender::nodes::node_shader_bsdf_hair_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_bsdf_hair_in[] = { - {SOCK_RGBA, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Offset"), 0.0f, 0.0f, 0.0f, 0.0f, -M_PI_2, M_PI_2, PROP_ANGLE}, - {SOCK_FLOAT, N_("RoughnessU"), 0.1f, 0.1f, 0.1f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("RoughnessV"), 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_VECTOR, N_("Tangent"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_bsdf_hair_out[] = { - {SOCK_SHADER, N_("BSDF")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input(N_("Offset")) + .default_value(0.0f) + .min(-M_PI_2) + .max(M_PI_2) + .subtype(PROP_ANGLE); + b.add_input(N_("RoughnessU")) + .default_value(0.1f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("RoughnessV")) + .default_value(1.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Tangent")).hide_value(); + b.add_output(N_("BSDF")); +} static int node_shader_gpu_bsdf_hair(GPUMaterial *mat, bNode *node, @@ -56,8 +62,7 @@ void register_node_type_sh_bsdf_hair() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_HAIR, "Hair BSDF", NODE_CLASS_SHADER); - node_type_socket_templates( - &ntype, file_ns::sh_node_bsdf_hair_in, file_ns::sh_node_bsdf_hair_out); + ntype.declare = file_ns::node_declare; node_type_size(&ntype, 150, 60, 200); node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_hair); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc index 16d48144578..948ea2ee6e1 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc @@ -21,38 +21,60 @@ namespace blender::nodes::node_shader_bsdf_hair_principled_cc { -/* **************** OUTPUT ******************** */ - /* Color, melanin and absorption coefficient default to approximately same brownish hair. */ -static bNodeSocketTemplate sh_node_bsdf_hair_principled_in[] = { - {SOCK_RGBA, N_("Color"), 0.017513f, 0.005763f, 0.002059f, 1.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Melanin"), 0.8f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Melanin Redness"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_RGBA, N_("Tint"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f}, - {SOCK_VECTOR, N_("Absorption Coefficient"), 0.245531f, 0.52f, 1.365f, 0.0f, 0.0f, 1000.0f}, - {SOCK_FLOAT, N_("Roughness"), 0.3f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Radial Roughness"), 0.3f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Coat"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("IOR"), 1.55f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - {SOCK_FLOAT, - N_("Offset"), - 2.0f * ((float)M_PI) / 180.0f, - 0.0f, - 0.0f, - 0.0f, - -M_PI_2, - M_PI_2, - PROP_ANGLE}, - {SOCK_FLOAT, N_("Random Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Random Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Random"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_bsdf_hair_principled_out[] = { - {SOCK_SHADER, N_("BSDF")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Color")).default_value({0.017513f, 0.005763f, 0.002059f, 1.0f}); + b.add_input(N_("Melanin")) + .default_value(0.8f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Melanin Redness")) + .default_value(1.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Tint")).default_value({1.0f, 1.0f, 1.0f, 1.0f}); + b.add_input(N_("Absorption Coefficient")) + .default_value({0.245531f, 0.52f, 1.365f}) + .min(0.0f) + .max(1000.0f); + b.add_input(N_("Roughness")) + .default_value(0.3f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Radial Roughness")) + .default_value(0.3f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Coat")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("IOR")).default_value(1.55f).min(0.0f).max(1000.0f).subtype( + PROP_FACTOR); + b.add_input(N_("Offset")) + .default_value(2.0f * ((float)M_PI) / 180.0f) + .min(-M_PI_2) + .max(M_PI_2) + .subtype(PROP_ANGLE); + b.add_input(N_("Random Color")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Random Roughness")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Random")).hide_value(); + b.add_output(N_("BSDF")); +} /* Initialize the custom Parametrization property to Color. */ static void node_shader_init_hair_principled(bNodeTree *UNUSED(ntree), bNode *node) @@ -103,8 +125,7 @@ void register_node_type_sh_bsdf_hair_principled() sh_node_type_base( &ntype, SH_NODE_BSDF_HAIR_PRINCIPLED, "Principled Hair BSDF", NODE_CLASS_SHADER); - node_type_socket_templates( - &ntype, file_ns::sh_node_bsdf_hair_principled_in, file_ns::sh_node_bsdf_hair_principled_out); + ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_init(&ntype, file_ns::node_shader_init_hair_principled); node_type_update(&ntype, file_ns::node_shader_update_hair_principled); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc index 72b2c278635..812f582e0dd 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc @@ -21,59 +21,103 @@ namespace blender::nodes::node_shader_bsdf_principled_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_bsdf_principled_in[] = { - {SOCK_RGBA, N_("Base Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Subsurface"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_VECTOR, - N_("Subsurface Radius"), - 1.0f, - 0.2f, - 0.1f, - 0.0f, - 0.0f, - 100.0f, - PROP_NONE, - SOCK_COMPACT}, - {SOCK_RGBA, N_("Subsurface Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Subsurface IOR"), 1.4f, 0.0f, 0.0f, 0.0f, 1.01f, 3.8f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Subsurface Anisotropy"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Metallic"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Specular"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Specular Tint"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Roughness"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Anisotropic"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Anisotropic Rotation"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Sheen"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Sheen Tint"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Clearcoat"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Clearcoat Roughness"), 0.03f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("IOR"), 1.45f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - {SOCK_FLOAT, N_("Transmission"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Transmission Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_RGBA, N_("Emission"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Emission Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000000.0f}, - {SOCK_FLOAT, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {SOCK_VECTOR, - N_("Clearcoat Normal"), - 0.0f, - 0.0f, - 0.0f, - 1.0f, - -1.0f, - 1.0f, - PROP_NONE, - SOCK_HIDE_VALUE}, - {SOCK_VECTOR, N_("Tangent"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_bsdf_principled_out[] = { - {SOCK_SHADER, N_("BSDF")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Base Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input(N_("Subsurface")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Subsurface Radius")) + .default_value({1.0f, 0.2f, 0.1f}) + .min(0.0f) + .max(100.0f) + .compact(); + b.add_input(N_("Subsurface Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input(N_("Subsurface IOR")) + .default_value(1.4f) + .min(1.01f) + .max(3.8f) + .subtype(PROP_FACTOR); + b.add_input(N_("Subsurface Anisotropy")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Metallic")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Specular")) + .default_value(0.5f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Specular Tint")) + .default_value(0.5f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Roughness")) + .default_value(0.5f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Anisotropic")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Anisotropic Rotation")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Sheen")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Sheen Tint")) + .default_value(0.5f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Clearcoat")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Clearcoat Roughness")) + .default_value(0.03f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("IOR")).default_value(1.45f).min(0.0f).max(1000.0f); + b.add_input(N_("Transmission")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Transmission Roughness")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Emission")).default_value({0.0f, 0.0f, 0.0f, 1.0f}); + b.add_input(N_("Emission Strength")).default_value(1.0).min(0.0f).max(1000000.0f); + b.add_input(N_("Alpha")) + .default_value(1.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Normal")).hide_value(); + b.add_input(N_("Clearcoat Normal")).hide_value(); + b.add_input(N_("Tangent")).hide_value(); + b.add_output(N_("BSDF")); +} static void node_shader_init_principled(bNodeTree *UNUSED(ntree), bNode *node) { @@ -195,8 +239,7 @@ void register_node_type_sh_bsdf_principled() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_PRINCIPLED, "Principled BSDF", NODE_CLASS_SHADER); - node_type_socket_templates( - &ntype, file_ns::sh_node_bsdf_principled_in, file_ns::sh_node_bsdf_principled_out); + ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_init(&ntype, file_ns::node_shader_init_principled); node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_principled); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.cc index 63bca201898..0d588c82869 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.cc @@ -21,20 +21,18 @@ namespace blender::nodes::node_shader_bsdf_refraction_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_bsdf_refraction_in[] = { - {SOCK_RGBA, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("IOR"), 1.45f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_bsdf_refraction_out[] = { - {SOCK_SHADER, N_("BSDF")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Color")).default_value({1.0f, 1.0f, 1.0f, 1.0f}); + b.add_input(N_("Roughness")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("IOR")).default_value(1.45f).min(0.0f).max(1000.0f); + b.add_input(N_("Normal")).hide_value(); + b.add_output(N_("BSDF")); +} static void node_shader_init_refraction(bNodeTree *UNUSED(ntree), bNode *node) { @@ -70,8 +68,7 @@ void register_node_type_sh_bsdf_refraction() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_REFRACTION, "Refraction BSDF", NODE_CLASS_SHADER); - node_type_socket_templates( - &ntype, file_ns::sh_node_bsdf_refraction_in, file_ns::sh_node_bsdf_refraction_out); + ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, file_ns::node_shader_init_refraction); node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_refraction); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc index 270288c3ce0..80586a5169d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc @@ -21,20 +21,22 @@ namespace blender::nodes::node_shader_bsdf_toon_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_bsdf_toon_in[] = { - {SOCK_RGBA, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Size"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Smooth"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_bsdf_toon_out[] = { - {SOCK_SHADER, N_("BSDF")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input(N_("Size")) + .default_value(0.5f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Smooth")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Normal")).hide_value(); + b.add_output(N_("BSDF")); +} static int node_shader_gpu_bsdf_toon(GPUMaterial *mat, bNode *node, @@ -61,8 +63,7 @@ void register_node_type_sh_bsdf_toon() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_TOON, "Toon BSDF", NODE_CLASS_SHADER); - node_type_socket_templates( - &ntype, file_ns::sh_node_bsdf_toon_in, file_ns::sh_node_bsdf_toon_out); + ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_toon); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.cc index 421c7c16032..22891738299 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.cc @@ -21,18 +21,12 @@ namespace blender::nodes::node_shader_bsdf_translucent_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_bsdf_translucent_in[] = { - {SOCK_RGBA, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, - {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_bsdf_translucent_out[] = { - {SOCK_SHADER, N_("BSDF")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input(N_("Normal")).hide_value(); + b.add_output(N_("BSDF")); +} static int node_shader_gpu_bsdf_translucent(GPUMaterial *mat, bNode *node, @@ -59,8 +53,7 @@ void register_node_type_sh_bsdf_translucent() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_TRANSLUCENT, "Translucent BSDF", NODE_CLASS_SHADER); - node_type_socket_templates( - &ntype, file_ns::sh_node_bsdf_translucent_in, file_ns::sh_node_bsdf_translucent_out); + ntype.declare = file_ns::node_declare; node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_translucent); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.cc index d1dc1856863..d764f4dd76b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.cc @@ -21,17 +21,11 @@ namespace blender::nodes::node_shader_bsdf_transparent_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_bsdf_transparent_in[] = { - {SOCK_RGBA, N_("Color"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_bsdf_transparent_out[] = { - {SOCK_SHADER, N_("BSDF")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Color")).default_value({1.0f, 1.0f, 1.0f, 1.0f}); + b.add_output(N_("BSDF")); +} static int node_shader_gpu_bsdf_transparent(GPUMaterial *mat, bNode *node, @@ -52,8 +46,7 @@ void register_node_type_sh_bsdf_transparent() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_TRANSPARENT, "Transparent BSDF", NODE_CLASS_SHADER); - node_type_socket_templates( - &ntype, file_ns::sh_node_bsdf_transparent_in, file_ns::sh_node_bsdf_transparent_out); + ntype.declare = file_ns::node_declare; node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_transparent); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.cc index 6293f38d792..dd090236c08 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.cc @@ -21,19 +21,17 @@ namespace blender::nodes::node_shader_bsdf_velvet_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_bsdf_velvet_in[] = { - {SOCK_RGBA, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Sigma"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_bsdf_velvet_out[] = { - {SOCK_SHADER, N_("BSDF")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input(N_("Sigma")) + .default_value(1.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Normal")).hide_value(); + b.add_output(N_("BSDF")); +} static int node_shader_gpu_bsdf_velvet(GPUMaterial *mat, bNode *node, @@ -60,8 +58,7 @@ void register_node_type_sh_bsdf_velvet() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BSDF_VELVET, "Velvet BSDF", NODE_CLASS_SHADER); - node_type_socket_templates( - &ntype, file_ns::sh_node_bsdf_velvet_in, file_ns::sh_node_bsdf_velvet_out); + ntype.declare = file_ns::node_declare; node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_velvet); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_eevee_specular.cc b/source/blender/nodes/shader/nodes/node_shader_eevee_specular.cc index aa34ba225a2..e4c80725c8e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_eevee_specular.cc +++ b/source/blender/nodes/shader/nodes/node_shader_eevee_specular.cc @@ -21,44 +21,36 @@ namespace blender::nodes::node_shader_eevee_specular_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_eevee_specular_in[] = { - {SOCK_RGBA, N_("Base Color"), 0.8f, 0.8f, 0.8f, 1.0f}, - {SOCK_RGBA, N_("Specular"), 0.03f, 0.03f, 0.03f, 1.0f}, - {SOCK_FLOAT, N_("Roughness"), 0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_RGBA, N_("Emissive Color"), 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Transparency"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {SOCK_FLOAT, N_("Clear Coat"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Clear Coat Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_VECTOR, - N_("Clear Coat Normal"), - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 1.0f, - PROP_NONE, - SOCK_HIDE_VALUE}, - {SOCK_FLOAT, - N_("Ambient Occlusion"), - 1.0f, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 1.0f, - PROP_NONE, - SOCK_HIDE_VALUE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_eevee_specular_out[] = { - {SOCK_SHADER, N_("BSDF")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Base Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input(N_("Specular")).default_value({0.03f, 0.03f, 0.03f, 1.0f}); + b.add_input(N_("Roughness")) + .default_value(0.2f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Emissive Color")).default_value({0.0f, 0.0f, 0.0f, 1.0f}); + b.add_input(N_("Transparency")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Normal")).hide_value(); + b.add_input(N_("Clear Coat")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Clear Coat Roughness")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Clear Coat Normal")).hide_value(); + b.add_input(N_("Ambient Occlusion")).hide_value(); + b.add_output(N_("BSDF")); +} static int node_shader_gpu_eevee_specular(GPUMaterial *mat, bNode *node, @@ -98,8 +90,7 @@ void register_node_type_sh_eevee_specular() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_EEVEE_SPECULAR, "Specular BSDF", NODE_CLASS_SHADER); - node_type_socket_templates( - &ntype, file_ns::sh_node_eevee_specular_in, file_ns::sh_node_eevee_specular_out); + ntype.declare = file_ns::node_declare; node_type_gpu(&ntype, file_ns::node_shader_gpu_eevee_specular); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_emission.cc b/source/blender/nodes/shader/nodes/node_shader_emission.cc index 47e4d3ad399..ea36763578f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_emission.cc +++ b/source/blender/nodes/shader/nodes/node_shader_emission.cc @@ -21,18 +21,12 @@ namespace blender::nodes::node_shader_emission_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_emission_in[] = { - {SOCK_RGBA, N_("Color"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000000.0f}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_emission_out[] = { - {SOCK_SHADER, N_("Emission")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Color")).default_value({1.0f, 1.0f, 1.0f, 1.0f}); + b.add_input(N_("Strength")).default_value(1.0f).min(0.0f).max(1000000.0f); + b.add_output(N_("Emission")); +} static int node_shader_gpu_emission(GPUMaterial *mat, bNode *node, @@ -53,7 +47,7 @@ void register_node_type_sh_emission() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_EMISSION, "Emission", NODE_CLASS_SHADER); - node_type_socket_templates(&ntype, file_ns::sh_node_emission_in, file_ns::sh_node_emission_out); + ntype.declare = file_ns::node_declare; node_type_gpu(&ntype, file_ns::node_shader_gpu_emission); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc index a5820aef194..5f02fe54745 100644 --- a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc +++ b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc @@ -21,22 +21,25 @@ namespace blender::nodes::node_shader_subsurface_scattering_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_subsurface_scattering_in[] = { - {SOCK_RGBA, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Scale"), 1.0, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - {SOCK_VECTOR, N_("Radius"), 1.0f, 0.2f, 0.1f, 0.0f, 0.0f, 100.0f, PROP_NONE, SOCK_COMPACT}, - {SOCK_FLOAT, N_("IOR"), 1.4f, 0.0f, 0.0f, 0.0f, 1.01f, 3.8f, PROP_FACTOR}, - {SOCK_FLOAT, N_("Anisotropy"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_subsurface_scattering_out[] = { - {SOCK_SHADER, N_("BSSRDF")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input(N_("Scale")).default_value(1.0f).min(0.0f).max(1000.0f); + b.add_input(N_("Radius")) + .default_value({1.0f, 0.2f, 0.1f}) + .min(0.0f) + .max(100.0f) + .compact(); + b.add_input(N_("IOR")).default_value(1.4f).min(1.01f).max(3.8f).subtype( + PROP_FACTOR); + b.add_input(N_("Anisotropy")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Normal")).hide_value(); + b.add_output(N_("BSSRDF")); +} static void node_shader_init_subsurface_scattering(bNodeTree *UNUSED(ntree), bNode *node) { @@ -91,9 +94,7 @@ void register_node_type_sh_subsurface_scattering() sh_node_type_base( &ntype, SH_NODE_SUBSURFACE_SCATTERING, "Subsurface Scattering", NODE_CLASS_SHADER); - node_type_socket_templates(&ntype, - file_ns::sh_node_subsurface_scattering_in, - file_ns::sh_node_subsurface_scattering_out); + ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, file_ns::node_shader_init_subsurface_scattering); node_type_gpu(&ntype, file_ns::node_shader_gpu_subsurface_scattering); diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_absorption.cc b/source/blender/nodes/shader/nodes/node_shader_volume_absorption.cc index cd697c96d66..a31bfdb6543 100644 --- a/source/blender/nodes/shader/nodes/node_shader_volume_absorption.cc +++ b/source/blender/nodes/shader/nodes/node_shader_volume_absorption.cc @@ -21,18 +21,12 @@ namespace blender::nodes::node_shader_volume_absorption_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_volume_absorption_in[] = { - {SOCK_RGBA, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Density"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_volume_absorption_out[] = { - {SOCK_SHADER, N_("Volume")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input(N_("Density")).default_value(1.0f).min(0.0f).max(1000.0f); + b.add_output(N_("Volume")); +} static int node_shader_gpu_volume_absorption(GPUMaterial *mat, bNode *node, @@ -53,8 +47,7 @@ void register_node_type_sh_volume_absorption() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_VOLUME_ABSORPTION, "Volume Absorption", NODE_CLASS_SHADER); - node_type_socket_templates( - &ntype, file_ns::sh_node_volume_absorption_in, file_ns::sh_node_volume_absorption_out); + ntype.declare = file_ns::node_declare; node_type_gpu(&ntype, file_ns::node_shader_gpu_volume_absorption); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_principled.cc b/source/blender/nodes/shader/nodes/node_shader_volume_principled.cc index 3acf8c35ac1..54e92eafcf6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_volume_principled.cc +++ b/source/blender/nodes/shader/nodes/node_shader_volume_principled.cc @@ -21,28 +21,30 @@ namespace blender::nodes::node_shader_volume_principled_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_volume_principled_in[] = { - {SOCK_RGBA, N_("Color"), 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f}, - {SOCK_STRING, N_("Color Attribute"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Density"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - {SOCK_STRING, N_("Density Attribute"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Anisotropy"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_FACTOR}, - {SOCK_RGBA, N_("Absorption Color"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Emission Strength"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1000.0f}, - {SOCK_RGBA, N_("Emission Color"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Blackbody Intensity"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_RGBA, N_("Blackbody Tint"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Temperature"), 1000.0f, 0.0f, 0.0f, 0.0f, 0.0f, 6500.0f}, - {SOCK_STRING, N_("Temperature Attribute"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_volume_principled_out[] = { - {SOCK_SHADER, N_("Volume")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Color")).default_value({0.5f, 0.5f, 0.5f, 1.0f}); + b.add_input(N_("Color Attribute")); + b.add_input(N_("Density")).default_value(1.0f).min(0.0f).max(1000.0f); + b.add_input(N_("Density Attribute")); + b.add_input(N_("Anisotropy")) + .default_value(0.0f) + .min(-1.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Absorption Color")).default_value({0.0f, 0.0f, 0.0f, 1.0f}); + b.add_input(N_("Emission Strength")).default_value(0.0f).min(0.0f).max(1000.0f); + b.add_input(N_("Emission Color")).default_value({1.0f, 1.0f, 1.0f, 1.0f}); + b.add_input(N_("Blackbody Intensity")) + .default_value(0.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input(N_("Blackbody Tint")).default_value({1.0f, 1.0f, 1.0f, 1.0f}); + b.add_input(N_("Temperature")).default_value(1000.0f).min(0.0f).max(6500.0f); + b.add_input(N_("Temperature Attribute")); + b.add_output(N_("Volume")); +} static void node_shader_init_volume_principled(bNodeTree *UNUSED(ntree), bNode *node) { @@ -138,8 +140,7 @@ void register_node_type_sh_volume_principled() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_VOLUME_PRINCIPLED, "Principled Volume", NODE_CLASS_SHADER); - node_type_socket_templates( - &ntype, file_ns::sh_node_volume_principled_in, file_ns::sh_node_volume_principled_out); + ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_init(&ntype, file_ns::node_shader_init_volume_principled); node_type_gpu(&ntype, file_ns::node_shader_gpu_volume_principled); -- cgit v1.2.3 From 34e84d0ee8a238d1ce46dc06e30c2c56693285dd Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 7 Jan 2022 16:16:34 -0600 Subject: Cleanup: Remove unused code from BKE_node.h Remove a variety of unused functions, declarations without definitions, incorrect comments, and defines that have been commented for years --- source/blender/nodes/shader/node_shader_tree.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/nodes/shader') diff --git a/source/blender/nodes/shader/node_shader_tree.cc b/source/blender/nodes/shader/node_shader_tree.cc index 0fa977aa63c..8f1bb1dcd9a 100644 --- a/source/blender/nodes/shader/node_shader_tree.cc +++ b/source/blender/nodes/shader/node_shader_tree.cc @@ -665,8 +665,8 @@ static bNode *ntree_shader_copy_branch(bNodeTree *ntree, LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->tmp_flag >= 0) { int id = node->tmp_flag; - nodes_copy[id] = BKE_node_copy( - ntree, node, LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_CREATE_NO_MAIN, false); + nodes_copy[id] = blender::bke::node_copy( + ntree, *node, LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_CREATE_NO_MAIN, false); nodes_copy[id]->tmp_flag = -2; /* Copy */ /* Make sure to clear all sockets links as they are invalid. */ LISTBASE_FOREACH (bNodeSocket *, sock, &nodes_copy[id]->inputs) { -- cgit v1.2.3 From 90e5ce6ab513e733dddecddb65ed4f303c5589f7 Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Fri, 7 Jan 2022 23:38:35 -0500 Subject: Cleanup: Loop through socket listbase instead of array The socket arrays will be removed when using the new socket builder. So instead we have to loop through the node outputs list. --- source/blender/nodes/shader/nodes/node_shader_attribute.cc | 3 ++- source/blender/nodes/shader/nodes/node_shader_tex_coord.cc | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'source/blender/nodes/shader') diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.cc b/source/blender/nodes/shader/nodes/node_shader_attribute.cc index 780d0a72ef8..3e9c57df7cf 100644 --- a/source/blender/nodes/shader/nodes/node_shader_attribute.cc +++ b/source/blender/nodes/shader/nodes/node_shader_attribute.cc @@ -76,7 +76,8 @@ static int node_shader_gpu_attribute(GPUMaterial *mat, GPU_stack_link(mat, node, "node_attribute", in, out, cd_attr); /* for each output. */ - for (int i = 0; sh_node_attribute_out[i].type != -1; i++) { + int i; + LISTBASE_FOREACH_INDEX (bNodeSocket *, sock, &node->outputs, i) { node_shader_gpu_bump_tex_coord(mat, node, &out[i].link); } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc b/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc index 9372d29456d..723458b7321 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc @@ -63,8 +63,8 @@ static int node_shader_gpu_tex_coord(GPUMaterial *mat, GPU_stack_link( mat, node, "node_tex_coord", in, out, viewpos, worldnor, inv_obmat, texcofacs, orco, mtface); - /* for each output. */ - for (int i = 0; sh_node_tex_coord_out[i].type != -1; i++) { + int i; + LISTBASE_FOREACH_INDEX (bNodeSocket *, sock, &node->outputs, i) { node_shader_gpu_bump_tex_coord(mat, node, &out[i].link); /* Normalize some vectors after dFdx/dFdy offsets. * This is the case for interpolated, non linear functions. -- cgit v1.2.3 From 937aa8e1142300e0ba82f6f9b9ddb9908be54b9c Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Fri, 7 Jan 2022 23:52:19 -0500 Subject: Cleanup: Use new socket builder API --- .../nodes/shader/nodes/node_shader_attribute.cc | 19 +++++----- .../nodes/shader/nodes/node_shader_background.cc | 21 ++++-------- .../nodes/shader/nodes/node_shader_bevel.cc | 20 ++++------- .../nodes/shader/nodes/node_shader_brightness.cc | 23 +++++-------- .../nodes/shader/nodes/node_shader_fresnel.cc | 19 ++++------ .../nodes/shader/nodes/node_shader_hair_info.cc | 22 ++++++------ .../nodes/shader/nodes/node_shader_light_path.cc | 36 +++++++++---------- .../nodes/shader/nodes/node_shader_sepcomb_hsv.cc | 40 ++++++++++------------ .../nodes/shader/nodes/node_shader_squeeze.cc | 17 +++++---- .../shader/nodes/node_shader_vector_transform.cc | 19 +++++----- 10 files changed, 100 insertions(+), 136 deletions(-) (limited to 'source/blender/nodes/shader') diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.cc b/source/blender/nodes/shader/nodes/node_shader_attribute.cc index 3e9c57df7cf..8cf48306641 100644 --- a/source/blender/nodes/shader/nodes/node_shader_attribute.cc +++ b/source/blender/nodes/shader/nodes/node_shader_attribute.cc @@ -21,15 +21,13 @@ namespace blender::nodes::node_shader_attribute_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_attribute_out[] = { - {SOCK_RGBA, N_("Color")}, - {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_FACTOR}, - {SOCK_FLOAT, N_("Alpha"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_FACTOR}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_output(N_("Color")); + b.add_output(N_("Vector")); + b.add_output(N_("Fac")); + b.add_output(N_("Alpha")); +} static void node_shader_init_attribute(bNodeTree *UNUSED(ntree), bNode *node) { @@ -75,7 +73,6 @@ static int node_shader_gpu_attribute(GPUMaterial *mat, GPU_stack_link(mat, node, "node_attribute", in, out, cd_attr); - /* for each output. */ int i; LISTBASE_FOREACH_INDEX (bNodeSocket *, sock, &node->outputs, i) { node_shader_gpu_bump_tex_coord(mat, node, &out[i].link); @@ -94,7 +91,7 @@ void register_node_type_sh_attribute() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_ATTRIBUTE, "Attribute", NODE_CLASS_INPUT); - node_type_socket_templates(&ntype, nullptr, file_ns::sh_node_attribute_out); + ntype.declare = file_ns::node_declare; node_type_init(&ntype, file_ns::node_shader_init_attribute); node_type_storage( &ntype, "NodeShaderAttribute", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_background.cc b/source/blender/nodes/shader/nodes/node_shader_background.cc index 39858e36fd1..3b9e71cf842 100644 --- a/source/blender/nodes/shader/nodes/node_shader_background.cc +++ b/source/blender/nodes/shader/nodes/node_shader_background.cc @@ -21,18 +21,12 @@ namespace blender::nodes::node_shader_background_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_background_in[] = { - {SOCK_RGBA, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000000.0f}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_background_out[] = { - {SOCK_SHADER, N_("Background")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input(N_("Strength")).default_value(1.0f).min(0.0f).max(1000000.0f); + b.add_output(N_("Background")); +} static int node_shader_gpu_background(GPUMaterial *mat, bNode *node, @@ -53,8 +47,7 @@ void register_node_type_sh_background() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BACKGROUND, "Background", NODE_CLASS_SHADER); - node_type_socket_templates( - &ntype, file_ns::sh_node_background_in, file_ns::sh_node_background_out); + ntype.declare = file_ns::node_declare; node_type_gpu(&ntype, file_ns::node_shader_gpu_background); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_bevel.cc b/source/blender/nodes/shader/nodes/node_shader_bevel.cc index a3063358556..aa38eea273c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bevel.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bevel.cc @@ -21,18 +21,12 @@ namespace blender::nodes::node_shader_bevel_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_bevel_in[] = { - {SOCK_FLOAT, N_("Radius"), 0.05f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_bevel_out[] = { - {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Radius")).default_value(0.05f).min(0.0f).max(1000.0f); + b.add_input(N_("Normal")).hide_value(); + b.add_output(N_("Normal")); +} static void node_shader_init_bevel(bNodeTree *UNUSED(ntree), bNode *node) { @@ -66,7 +60,7 @@ void register_node_type_sh_bevel() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BEVEL, "Bevel", NODE_CLASS_INPUT); - node_type_socket_templates(&ntype, file_ns::sh_node_bevel_in, file_ns::sh_node_bevel_out); + ntype.declare = file_ns::node_declare; node_type_init(&ntype, file_ns::node_shader_init_bevel); node_type_gpu(&ntype, file_ns::gpu_shader_bevel); diff --git a/source/blender/nodes/shader/nodes/node_shader_brightness.cc b/source/blender/nodes/shader/nodes/node_shader_brightness.cc index e6328c4972a..66bfaba2785 100644 --- a/source/blender/nodes/shader/nodes/node_shader_brightness.cc +++ b/source/blender/nodes/shader/nodes/node_shader_brightness.cc @@ -21,19 +21,13 @@ namespace blender::nodes::node_shader_brightness_cc { -/* **************** Bright and contrast ******************** */ - -static bNodeSocketTemplate sh_node_brightcontrast_in[] = { - {SOCK_RGBA, N_("Color"), 1.0f, 1.0f, 1.0f, 1.0f}, - {SOCK_FLOAT, N_("Bright"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, - {SOCK_FLOAT, N_("Contrast"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_brightcontrast_out[] = { - {SOCK_RGBA, N_("Color")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Color")).default_value({1.0f, 1.0f, 1.0f, 1.0f}); + b.add_input(N_("Bright")).default_value(0.0f).min(-100.0f).max(100.0f); + b.add_input(N_("Contrast")).default_value(0.0f).min(-100.0f).max(100.0f); + b.add_output(N_("Color")); +} static int gpu_shader_brightcontrast(GPUMaterial *mat, bNode *node, @@ -53,8 +47,7 @@ void register_node_type_sh_brightcontrast() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR); - node_type_socket_templates( - &ntype, file_ns::sh_node_brightcontrast_in, file_ns::sh_node_brightcontrast_out); + ntype.declare = file_ns::node_declare; node_type_gpu(&ntype, file_ns::gpu_shader_brightcontrast); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_fresnel.cc b/source/blender/nodes/shader/nodes/node_shader_fresnel.cc index 2abfb57a364..5dba42fcc30 100644 --- a/source/blender/nodes/shader/nodes/node_shader_fresnel.cc +++ b/source/blender/nodes/shader/nodes/node_shader_fresnel.cc @@ -21,17 +21,12 @@ namespace blender::nodes::node_shader_fresnel_cc { -/* **************** Fresnel ******************** */ -static bNodeSocketTemplate sh_node_fresnel_in[] = { - {SOCK_FLOAT, N_("IOR"), 1.45f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_fresnel_out[] = { - {SOCK_FLOAT, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("IOR")).default_value(1.45f).min(0.0f).max(1000.0f); + b.add_input(N_("Normal")).hide_value(); + b.add_output(N_("Fac")); +} static int node_shader_gpu_fresnel(GPUMaterial *mat, bNode *node, @@ -60,7 +55,7 @@ void register_node_type_sh_fresnel() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_FRESNEL, "Fresnel", NODE_CLASS_INPUT); - node_type_socket_templates(&ntype, file_ns::sh_node_fresnel_in, file_ns::sh_node_fresnel_out); + ntype.declare = file_ns::node_declare; node_type_gpu(&ntype, file_ns::node_shader_gpu_fresnel); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_hair_info.cc b/source/blender/nodes/shader/nodes/node_shader_hair_info.cc index c5af7e16201..e22a825c066 100644 --- a/source/blender/nodes/shader/nodes/node_shader_hair_info.cc +++ b/source/blender/nodes/shader/nodes/node_shader_hair_info.cc @@ -21,16 +21,16 @@ namespace blender::nodes::node_shader_hair_info_cc { -static bNodeSocketTemplate outputs[] = { - {SOCK_FLOAT, N_("Is Strand"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Intercept"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Length"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Thickness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_VECTOR, N_("Tangent Normal"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - // { SOCK_FLOAT, 0, N_("Fade"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Random")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_output(N_("Is Strand")); + b.add_output(N_("Intercept")); + b.add_output(N_("Length")); + b.add_output(N_("Thickness")); + b.add_output(N_("Tangent Normal")); + // b.add_output(N_("Fade")); + b.add_output(N_("Random")); +} static int node_shader_gpu_hair_info(GPUMaterial *mat, bNode *node, @@ -55,7 +55,7 @@ void register_node_type_sh_hair_info() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_HAIR_INFO, "Hair Info", NODE_CLASS_INPUT); - node_type_socket_templates(&ntype, nullptr, file_ns::outputs); + ntype.declare = file_ns::node_declare; node_type_gpu(&ntype, file_ns::node_shader_gpu_hair_info); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_light_path.cc b/source/blender/nodes/shader/nodes/node_shader_light_path.cc index 9f8e6502ce5..6fbd5751886 100644 --- a/source/blender/nodes/shader/nodes/node_shader_light_path.cc +++ b/source/blender/nodes/shader/nodes/node_shader_light_path.cc @@ -21,24 +21,22 @@ namespace blender::nodes::node_shader_light_path_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_light_path_out[] = { - {SOCK_FLOAT, N_("Is Camera Ray"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Is Shadow Ray"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Is Diffuse Ray"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Is Glossy Ray"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Is Singular Ray"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Is Reflection Ray"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Is Transmission Ray"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Ray Length"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Ray Depth"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Diffuse Depth"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Glossy Depth"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Transparent Depth"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Transmission Depth"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_output(N_("Is Camera Ray")); + b.add_output(N_("Is Shadow Ray")); + b.add_output(N_("Is Diffuse Ray")); + b.add_output(N_("Is Glossy Ray")); + b.add_output(N_("Is Singular Ray")); + b.add_output(N_("Is Reflection Ray")); + b.add_output(N_("Is Transmission Ray")); + b.add_output(N_("Ray Length")); + b.add_output(N_("Ray Depth")); + b.add_output(N_("Diffuse Depth")); + b.add_output(N_("Glossy Depth")); + b.add_output(N_("Transparent Depth")); + b.add_output(N_("Transmission Depth")); +} static int node_shader_gpu_light_path(GPUMaterial *mat, bNode *node, @@ -59,7 +57,7 @@ void register_node_type_sh_light_path() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_LIGHT_PATH, "Light Path", NODE_CLASS_INPUT); - node_type_socket_templates(&ntype, nullptr, file_ns::sh_node_light_path_out); + ntype.declare = file_ns::node_declare; node_type_gpu(&ntype, file_ns::node_shader_gpu_light_path); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcomb_hsv.cc b/source/blender/nodes/shader/nodes/node_shader_sepcomb_hsv.cc index 44cdc5cd402..700e4ce3667 100644 --- a/source/blender/nodes/shader/nodes/node_shader_sepcomb_hsv.cc +++ b/source/blender/nodes/shader/nodes/node_shader_sepcomb_hsv.cc @@ -26,16 +26,14 @@ namespace blender::nodes::node_shader_sepcomb_hsv_cc { /* **************** SEPARATE HSV ******************** */ -static bNodeSocketTemplate sh_node_sephsv_in[] = { - {SOCK_RGBA, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f}, - {-1, ""}, -}; -static bNodeSocketTemplate sh_node_sephsv_out[] = { - {SOCK_FLOAT, N_("H")}, - {SOCK_FLOAT, N_("S")}, - {SOCK_FLOAT, N_("V")}, - {-1, ""}, -}; + +static void node_declare_sephsv(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0}); + b.add_output(N_("H")); + b.add_output(N_("S")); + b.add_output(N_("V")); +} static int gpu_shader_sephsv(GPUMaterial *mat, bNode *node, @@ -55,7 +53,7 @@ void register_node_type_sh_sephsv() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_SEPHSV, "Separate HSV", NODE_CLASS_CONVERTER); - node_type_socket_templates(&ntype, file_ns::sh_node_sephsv_in, file_ns::sh_node_sephsv_out); + ntype.declare = file_ns::node_declare_sephsv; node_type_gpu(&ntype, file_ns::gpu_shader_sephsv); nodeRegisterType(&ntype); @@ -64,16 +62,14 @@ void register_node_type_sh_sephsv() namespace blender::nodes::node_shader_sepcomb_hsv_cc { /* **************** COMBINE HSV ******************** */ -static bNodeSocketTemplate sh_node_combhsv_in[] = { - {SOCK_FLOAT, N_("H"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED}, - {SOCK_FLOAT, N_("S"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED}, - {SOCK_FLOAT, N_("V"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED}, - {-1, ""}, -}; -static bNodeSocketTemplate sh_node_combhsv_out[] = { - {SOCK_RGBA, N_("Color")}, - {-1, ""}, -}; + +static void node_declare_combhsv(NodeDeclarationBuilder &b) +{ + b.add_input(N_("H")).default_value(0.0f).min(0.0f).max(1.0f).subtype(PROP_UNSIGNED); + b.add_input(N_("S")).default_value(0.0f).min(0.0f).max(1.0f).subtype(PROP_UNSIGNED); + b.add_input(N_("V")).default_value(0.0f).min(0.0f).max(1.0f).subtype(PROP_UNSIGNED); + b.add_output(N_("Color")); +} static int gpu_shader_combhsv(GPUMaterial *mat, bNode *node, @@ -93,7 +89,7 @@ void register_node_type_sh_combhsv() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_COMBHSV, "Combine HSV", NODE_CLASS_CONVERTER); - node_type_socket_templates(&ntype, file_ns::sh_node_combhsv_in, file_ns::sh_node_combhsv_out); + ntype.declare = file_ns::node_declare_combhsv; node_type_gpu(&ntype, file_ns::gpu_shader_combhsv); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_squeeze.cc b/source/blender/nodes/shader/nodes/node_shader_squeeze.cc index f71b6a3e4e5..83965160019 100644 --- a/source/blender/nodes/shader/nodes/node_shader_squeeze.cc +++ b/source/blender/nodes/shader/nodes/node_shader_squeeze.cc @@ -25,14 +25,13 @@ namespace blender::nodes::node_shader_squeeze_cc { -/* **************** VALUE SQUEEZE ******************** */ -static bNodeSocketTemplate sh_node_squeeze_in[] = { - {SOCK_FLOAT, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, - {SOCK_FLOAT, N_("Width"), 1.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, - {SOCK_FLOAT, N_("Center"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, - {-1, ""}}; - -static bNodeSocketTemplate sh_node_squeeze_out[] = {{SOCK_FLOAT, N_("Value")}, {-1, ""}}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Value")).default_value(0.0f).min(-100.0f).max(100.0f); + b.add_input(N_("Width")).default_value(1.0f).min(-100.0f).max(100.0f); + b.add_input(N_("Center")).default_value(0.0f).min(-100.0f).max(100.0f); + b.add_output(N_("Value")); +} static int gpu_shader_squeeze(GPUMaterial *mat, bNode *node, @@ -52,7 +51,7 @@ void register_node_type_sh_squeeze() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_SQUEEZE, "Squeeze Value", NODE_CLASS_CONVERTER); - node_type_socket_templates(&ntype, file_ns::sh_node_squeeze_in, file_ns::sh_node_squeeze_out); + ntype.declare = file_ns::node_declare; node_type_gpu(&ntype, file_ns::gpu_shader_squeeze); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc b/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc index 30bc3f020b1..d5960910042 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc @@ -25,14 +25,14 @@ namespace blender::nodes::node_shader_vector_transform_cc { -/* **************** Vector Transform ******************** */ -static bNodeSocketTemplate sh_node_vect_transform_in[] = { - {SOCK_VECTOR, N_("Vector"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, {-1, ""}}; - -static bNodeSocketTemplate sh_node_vect_transform_out[] = { - {SOCK_VECTOR, N_("Vector")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Vector")) + .default_value({0.5f, 0.5f, 0.5f}) + .min(-10000.0f) + .max(10000.0f); + b.add_output(N_("Vector")); +} static void node_shader_init_vect_transform(bNodeTree *UNUSED(ntree), bNode *node) { @@ -139,8 +139,7 @@ void register_node_type_sh_vect_transform() sh_node_type_base(&ntype, SH_NODE_VECT_TRANSFORM, "Vector Transform", NODE_CLASS_OP_VECTOR); node_type_init(&ntype, file_ns::node_shader_init_vect_transform); - node_type_socket_templates( - &ntype, file_ns::sh_node_vect_transform_in, file_ns::sh_node_vect_transform_out); + ntype.declare = file_ns::node_declare; node_type_storage( &ntype, "NodeShaderVectTransform", node_free_standard_storage, node_copy_standard_storage); node_type_gpu(&ntype, file_ns::gpu_shader_vect_transform); -- cgit v1.2.3 From 9620fdc9864405f9fe53493895f9e9d8592fe365 Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Sat, 8 Jan 2022 22:15:47 -0500 Subject: Cleanup: Remove no op socket templates --- source/blender/nodes/shader/nodes/node_shader_common.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'source/blender/nodes/shader') diff --git a/source/blender/nodes/shader/nodes/node_shader_common.cc b/source/blender/nodes/shader/nodes/node_shader_common.cc index 6f300890f7f..3f0fff34533 100644 --- a/source/blender/nodes/shader/nodes/node_shader_common.cc +++ b/source/blender/nodes/shader/nodes/node_shader_common.cc @@ -108,7 +108,6 @@ void register_node_type_sh_group() BLI_assert(ntype.rna_ext.srna != nullptr); RNA_struct_blender_type_set(ntype.rna_ext.srna, &ntype); - node_type_socket_templates(&ntype, nullptr, nullptr); node_type_size(&ntype, 140, 60, 400); ntype.labelfunc = node_group_label; node_type_group_update(&ntype, node_group_update); -- cgit v1.2.3 From ed1ced24848824a4acbaaf7aa7ccb34441f6a8f4 Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Sat, 8 Jan 2022 23:16:55 -0500 Subject: Cleanup: Use new socket builder API --- .../nodes/shader/nodes/node_shader_hueSatVal.cc | 24 ++++++-------- .../nodes/shader/nodes/node_shader_ies_light.cc | 20 ++++-------- .../nodes/shader/nodes/node_shader_invert.cc | 15 ++++----- .../nodes/shader/nodes/node_shader_layer_weight.cc | 23 +++++-------- .../shader/nodes/node_shader_light_falloff.cc | 27 +++++---------- .../nodes/shader/nodes/node_shader_mapping.cc | 38 ++++++++++++++-------- .../nodes/shader/nodes/node_shader_normal_map.cc | 21 ++++-------- .../nodes/shader/nodes/node_shader_tex_coord.cc | 24 +++++++------- .../shader/nodes/node_shader_tex_environment.cc | 19 ++++------- .../shader/nodes/node_shader_tex_pointdensity.cc | 21 ++++-------- .../nodes/shader/nodes/node_shader_tex_sky.cc | 18 ++++------ 11 files changed, 102 insertions(+), 148 deletions(-) (limited to 'source/blender/nodes/shader') diff --git a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.cc b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.cc index 75e1b372601..94b9a61c602 100644 --- a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.cc +++ b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.cc @@ -25,19 +25,15 @@ namespace blender::nodes::node_shader_hueSatVal_cc { -/* **************** Hue Saturation ******************** */ -static bNodeSocketTemplate sh_node_hue_sat_in[] = { - {SOCK_FLOAT, N_("Hue"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE}, - {SOCK_FLOAT, N_("Saturation"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, PROP_NONE}, - {SOCK_FLOAT, N_("Value"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, PROP_NONE}, - {SOCK_FLOAT, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_RGBA, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f}, - {-1, ""}, -}; -static bNodeSocketTemplate sh_node_hue_sat_out[] = { - {SOCK_RGBA, N_("Color")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Hue")).default_value(0.5f).min(0.0f).max(1.0f); + b.add_input(N_("Saturation")).default_value(1.0f).min(0.0f).max(2.0f); + b.add_input(N_("Value")).default_value(1.0f).min(0.0f).max(2.0f); + b.add_input(N_("Fac")).default_value(1.0f).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_output(N_("Color")); +} static int gpu_shader_hue_sat(GPUMaterial *mat, bNode *node, @@ -57,7 +53,7 @@ void register_node_type_sh_hue_sat() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_HUE_SAT, "Hue Saturation Value", NODE_CLASS_OP_COLOR); - node_type_socket_templates(&ntype, file_ns::sh_node_hue_sat_in, file_ns::sh_node_hue_sat_out); + ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_gpu(&ntype, file_ns::gpu_shader_hue_sat); diff --git a/source/blender/nodes/shader/nodes/node_shader_ies_light.cc b/source/blender/nodes/shader/nodes/node_shader_ies_light.cc index a107fd83b0e..481524dadc0 100644 --- a/source/blender/nodes/shader/nodes/node_shader_ies_light.cc +++ b/source/blender/nodes/shader/nodes/node_shader_ies_light.cc @@ -21,18 +21,12 @@ namespace blender::nodes::node_shader_ies_light_cc { -/* **************** IES Light ******************** */ - -static bNodeSocketTemplate sh_node_tex_ies_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_("Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000000.0f, PROP_NONE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_tex_ies_out[] = { - {SOCK_FLOAT, N_("Fac")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Vector")).hide_value(); + b.add_input(N_("Strength")).default_value(1.0f).min(0.0f).max(1000000.0f); + b.add_output(N_("Fac")); +} static void node_shader_init_tex_ies(bNodeTree *UNUSED(ntree), bNode *node) { @@ -50,7 +44,7 @@ void register_node_type_sh_tex_ies() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_TEX_IES, "IES Texture", NODE_CLASS_TEXTURE); - node_type_socket_templates(&ntype, file_ns::sh_node_tex_ies_in, file_ns::sh_node_tex_ies_out); + ntype.declare = file_ns::node_declare; node_type_init(&ntype, file_ns::node_shader_init_tex_ies); node_type_storage( &ntype, "NodeShaderTexIES", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_invert.cc b/source/blender/nodes/shader/nodes/node_shader_invert.cc index bcdb7ca7b00..3b5f4cb1d38 100644 --- a/source/blender/nodes/shader/nodes/node_shader_invert.cc +++ b/source/blender/nodes/shader/nodes/node_shader_invert.cc @@ -25,13 +25,12 @@ namespace blender::nodes::node_shader_invert_cc { -/* **************** INVERT ******************** */ -static bNodeSocketTemplate sh_node_invert_in[] = { - {SOCK_FLOAT, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_RGBA, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f}, - {-1, ""}}; - -static bNodeSocketTemplate sh_node_invert_out[] = {{SOCK_RGBA, N_("Color")}, {-1, ""}}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Fac")).default_value(1.0f).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input(N_("Color")).default_value({0.0f, 0.0f, 0.0f, 1.0f}); + b.add_output(N_("Color")); +} static int gpu_shader_invert(GPUMaterial *mat, bNode *node, @@ -51,7 +50,7 @@ void register_node_type_sh_invert() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_INVERT, "Invert", NODE_CLASS_OP_COLOR); - node_type_socket_templates(&ntype, file_ns::sh_node_invert_in, file_ns::sh_node_invert_out); + ntype.declare = file_ns::node_declare; node_type_gpu(&ntype, file_ns::gpu_shader_invert); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_layer_weight.cc b/source/blender/nodes/shader/nodes/node_shader_layer_weight.cc index f78bbcaacaa..b4210ce154c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_layer_weight.cc +++ b/source/blender/nodes/shader/nodes/node_shader_layer_weight.cc @@ -21,19 +21,13 @@ namespace blender::nodes::node_shader_layer_weight_cc { -/* **************** Layer Weight ******************** */ - -static bNodeSocketTemplate sh_node_layer_weight_in[] = { - {SOCK_FLOAT, N_("Blend"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_layer_weight_out[] = { - {SOCK_FLOAT, N_("Fresnel"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Facing"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Blend")).default_value(0.5f).min(0.0f).max(1.0f); + b.add_input(N_("Normal")).hide_value(); + b.add_output(N_("Fresnel")); + b.add_output(N_("Facing")); +} static int node_shader_gpu_layer_weight(GPUMaterial *mat, bNode *node, @@ -62,8 +56,7 @@ void register_node_type_sh_layer_weight() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_LAYER_WEIGHT, "Layer Weight", NODE_CLASS_INPUT); - node_type_socket_templates( - &ntype, file_ns::sh_node_layer_weight_in, file_ns::sh_node_layer_weight_out); + ntype.declare = file_ns::node_declare; node_type_gpu(&ntype, file_ns::node_shader_gpu_layer_weight); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_light_falloff.cc b/source/blender/nodes/shader/nodes/node_shader_light_falloff.cc index 6c2baa01e54..50eea2b3643 100644 --- a/source/blender/nodes/shader/nodes/node_shader_light_falloff.cc +++ b/source/blender/nodes/shader/nodes/node_shader_light_falloff.cc @@ -21,22 +21,14 @@ namespace blender::nodes::node_shader_light_falloff_cc { -/* **************** INPUT ********************* */ - -static bNodeSocketTemplate sh_node_light_falloff_in[] = { - {SOCK_FLOAT, N_("Strength"), 100.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000000.0f}, - {SOCK_FLOAT, N_("Smooth"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - {-1, ""}, -}; - -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_light_falloff_out[] = { - {SOCK_FLOAT, N_("Quadratic"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Linear"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Constant"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Strength")).default_value(100.0f).min(0.0f).max(1000000.0f); + b.add_input(N_("Smooth")).default_value(0.0f).min(0.0f).max(1000.0f); + b.add_output(N_("Quadratic")); + b.add_output(N_("Linear")); + b.add_output(N_("Constant")); +} static int node_shader_gpu_light_falloff(GPUMaterial *mat, bNode *node, @@ -57,8 +49,7 @@ void register_node_type_sh_light_falloff() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_LIGHT_FALLOFF, "Light Falloff", NODE_CLASS_OP_COLOR); - node_type_socket_templates( - &ntype, file_ns::sh_node_light_falloff_in, file_ns::sh_node_light_falloff_out); + ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_gpu(&ntype, file_ns::node_shader_gpu_light_falloff); diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.cc b/source/blender/nodes/shader/nodes/node_shader_mapping.cc index 758b675f9d6..4d25ae815d6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mapping.cc +++ b/source/blender/nodes/shader/nodes/node_shader_mapping.cc @@ -25,19 +25,29 @@ namespace blender::nodes::node_shader_mapping_cc { -/* **************** MAPPING ******************** */ -static bNodeSocketTemplate sh_node_mapping_in[] = { - {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 1.0f, -FLT_MAX, FLT_MAX, PROP_NONE}, - {SOCK_VECTOR, N_("Location"), 0.0f, 0.0f, 0.0f, 1.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION}, - {SOCK_VECTOR, N_("Rotation"), 0.0f, 0.0f, 0.0f, 1.0f, -FLT_MAX, FLT_MAX, PROP_EULER}, - {SOCK_VECTOR, N_("Scale"), 1.0f, 1.0f, 1.0f, 1.0f, -FLT_MAX, FLT_MAX, PROP_XYZ}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_mapping_out[] = { - {SOCK_VECTOR, N_("Vector")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Vector")) + .default_value({0.0f, 0.0f, 0.0f}) + .min(-FLT_MAX) + .max(FLT_MAX); + b.add_input(N_("Location")) + .default_value({0.0f, 0.0f, 0.0f}) + .min(-FLT_MAX) + .max(FLT_MAX) + .subtype(PROP_TRANSLATION); + b.add_input(N_("Rotation")) + .default_value({0.0f, 0.0f, 0.0f}) + .min(-FLT_MAX) + .max(FLT_MAX) + .subtype(PROP_EULER); + b.add_input(N_("Scale")) + .default_value({1.0f, 1.0f, 1.0f}) + .min(-FLT_MAX) + .max(FLT_MAX) + .subtype(PROP_XYZ); + b.add_output(N_("Vector")); +} static const char *gpu_shader_get_name(int mode) { @@ -83,7 +93,7 @@ void register_node_type_sh_mapping() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_MAPPING, "Mapping", NODE_CLASS_OP_VECTOR); - node_type_socket_templates(&ntype, file_ns::sh_node_mapping_in, file_ns::sh_node_mapping_out); + ntype.declare = file_ns::node_declare; node_type_gpu(&ntype, file_ns::gpu_shader_mapping); node_type_update(&ntype, file_ns::node_shader_update_mapping); diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.cc b/source/blender/nodes/shader/nodes/node_shader_normal_map.cc index ca75a29e6fe..cd99d0a64c9 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal_map.cc +++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.cc @@ -21,18 +21,12 @@ namespace blender::nodes::node_shader_normal_map_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_normal_map_in[] = { - {SOCK_FLOAT, N_("Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f}, - {SOCK_RGBA, N_("Color"), 0.5f, 0.5f, 1.0f, 1.0f, 0.0f, 1.0f}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_normal_map_out[] = { - {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Strength")).default_value(1.0f).min(0.0f).max(10.0f); + b.add_input(N_("Color")).default_value({0.5f, 0.5f, 1.0f, 1.0f}); + b.add_output(N_("Normal")); +} static void node_shader_init_normal_map(bNodeTree *UNUSED(ntree), bNode *node) { @@ -118,8 +112,7 @@ void register_node_type_sh_normal_map() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_NORMAL_MAP, "Normal Map", NODE_CLASS_OP_VECTOR); - node_type_socket_templates( - &ntype, file_ns::sh_node_normal_map_in, file_ns::sh_node_normal_map_out); + ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, file_ns::node_shader_init_normal_map); node_type_storage( diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc b/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc index 723458b7321..31f85441a80 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc @@ -23,18 +23,16 @@ namespace blender::nodes::node_shader_tex_coord_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_tex_coord_out[] = { - {SOCK_VECTOR, N_("Generated"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_VECTOR, N_("UV"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_VECTOR, N_("Object"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_VECTOR, N_("Camera"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_VECTOR, N_("Window"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {SOCK_VECTOR, N_("Reflection"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_output(N_("Generated")); + b.add_output(N_("Normal")); + b.add_output(N_("UV")); + b.add_output(N_("Object")); + b.add_output(N_("Camera")); + b.add_output(N_("Window")); + b.add_output(N_("Reflection")); +} static int node_shader_gpu_tex_coord(GPUMaterial *mat, bNode *node, @@ -95,7 +93,7 @@ void register_node_type_sh_tex_coord() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_TEX_COORD, "Texture Coordinate", NODE_CLASS_INPUT); - node_type_socket_templates(&ntype, nullptr, file_ns::sh_node_tex_coord_out); + ntype.declare = file_ns::node_declare; node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_coord); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.cc b/source/blender/nodes/shader/nodes/node_shader_tex_environment.cc index aa96d075f7f..7b947392084 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.cc @@ -21,17 +21,11 @@ namespace blender::nodes::node_shader_tex_environment_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_tex_environment_in[] = { - {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_tex_environment_out[] = { - {SOCK_RGBA, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_NO_INTERNAL_LINK}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Vector")).hide_value(); + b.add_output(N_("Color")).no_muted_links(); +} static void node_shader_init_tex_environment(bNodeTree *UNUSED(ntree), bNode *node) { @@ -144,8 +138,7 @@ void register_node_type_sh_tex_environment() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_TEX_ENVIRONMENT, "Environment Texture", NODE_CLASS_TEXTURE); - node_type_socket_templates( - &ntype, file_ns::sh_node_tex_environment_in, file_ns::sh_node_tex_environment_out); + ntype.declare = file_ns::node_declare; node_type_init(&ntype, file_ns::node_shader_init_tex_environment); node_type_storage( &ntype, "NodeTexEnvironment", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.cc b/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.cc index 31d14d09963..8a42577d35c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.cc @@ -23,18 +23,12 @@ namespace blender::nodes::node_shader_tex_pointdensity_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_tex_pointdensity_in[] = { - {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_tex_pointdensity_out[] = { - {SOCK_RGBA, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, - {SOCK_FLOAT, N_("Density"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Vector")).hide_value(); + b.add_output(N_("Color")); + b.add_output(N_("Density")); +} static void node_shader_init_tex_pointdensity(bNodeTree *UNUSED(ntree), bNode *node) { @@ -76,8 +70,7 @@ void register_node_type_sh_tex_pointdensity() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_TEX_POINTDENSITY, "Point Density", NODE_CLASS_TEXTURE); - node_type_socket_templates( - &ntype, file_ns::sh_node_tex_pointdensity_in, file_ns::sh_node_tex_pointdensity_out); + ntype.declare = file_ns::node_declare; node_type_init(&ntype, file_ns::node_shader_init_tex_pointdensity); node_type_storage(&ntype, "NodeShaderTexPointDensity", diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc b/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc index 30ec746c2d0..209d71db1ff 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc @@ -22,17 +22,11 @@ namespace blender::nodes::node_shader_tex_sky_cc { -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_tex_sky_in[] = { - {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_tex_sky_out[] = { - {SOCK_RGBA, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_NO_INTERNAL_LINK}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Vector")).hide_value(); + b.add_output(N_("Color")).no_muted_links(); +} static void node_shader_init_tex_sky(bNodeTree *UNUSED(ntree), bNode *node) { @@ -215,7 +209,7 @@ void register_node_type_sh_tex_sky() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_TEX_SKY, "Sky Texture", NODE_CLASS_TEXTURE); - node_type_socket_templates(&ntype, file_ns::sh_node_tex_sky_in, file_ns::sh_node_tex_sky_out); + ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, file_ns::node_shader_init_tex_sky); node_type_storage(&ntype, "NodeTexSky", node_free_standard_storage, node_copy_standard_storage); -- cgit v1.2.3 From e17ac8dc58c7108cfb3a784a595912c063e09cf4 Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Sun, 9 Jan 2022 00:59:34 -0500 Subject: Cleanup: Nodes: Begin splitting shader node buttons into individual files Currently, most node buttons are defined in `drawnode.cc` however, this is inconvenient because it requires editing many files when adding new nodes. The goal is to minimize the number of files needed to add or update a node. This commit moves most of the node layout functions for shader nodes into their respected source/blender/nodes/shader/nodes file. In the future, these functions will be simplified to node_layout. Some nodes were left in `drawnode.cc` as this would require duplicating code while this is likely fine it is best to leave that to a seperate commit. --- .../shader/nodes/node_shader_ambient_occlusion.cc | 13 ++++++ .../nodes/shader/nodes/node_shader_attribute.cc | 10 +++++ .../nodes/shader/nodes/node_shader_bevel.cc | 9 ++++ .../shader/nodes/node_shader_bsdf_anisotropic.cc | 9 ++++ .../nodes/shader/nodes/node_shader_bsdf_hair.cc | 9 ++++ .../nodes/node_shader_bsdf_hair_principled.cc | 11 +++++ .../shader/nodes/node_shader_bsdf_principled.cc | 10 +++++ .../nodes/shader/nodes/node_shader_bsdf_toon.cc | 9 ++++ .../blender/nodes/shader/nodes/node_shader_bump.cc | 9 ++++ .../nodes/shader/nodes/node_shader_clamp.cc | 9 ++++ .../nodes/shader/nodes/node_shader_ies_light.cc | 21 +++++++++ .../nodes/shader/nodes/node_shader_map_range.cc | 15 +++++++ .../nodes/shader/nodes/node_shader_mapping.cc | 9 ++++ .../nodes/shader/nodes/node_shader_normal_map.cc | 23 ++++++++++ .../nodes/shader/nodes/node_shader_output_aov.cc | 9 ++++ .../shader/nodes/node_shader_output_linestyle.cc | 14 ++++++ .../nodes/shader/nodes/node_shader_script.cc | 37 +++++++++++++++- .../nodes/node_shader_subsurface_scattering.cc | 9 ++++ .../nodes/shader/nodes/node_shader_tangent.cc | 32 ++++++++++++++ .../nodes/shader/nodes/node_shader_tex_brick.cc | 24 +++++++++++ .../nodes/shader/nodes/node_shader_tex_coord.cc | 10 +++++ .../nodes/shader/nodes/node_shader_tex_gradient.cc | 9 ++++ .../nodes/shader/nodes/node_shader_tex_magic.cc | 9 ++++ .../nodes/shader/nodes/node_shader_tex_musgrave.cc | 10 +++++ .../nodes/shader/nodes/node_shader_tex_noise.cc | 9 ++++ .../shader/nodes/node_shader_tex_pointdensity.cc | 50 ++++++++++++++++++++++ .../nodes/shader/nodes/node_shader_tex_sky.cc | 47 ++++++++++++++++++++ .../nodes/shader/nodes/node_shader_tex_voronoi.cc | 15 +++++++ .../nodes/shader/nodes/node_shader_tex_wave.cc | 18 ++++++++ .../shader/nodes/node_shader_tex_white_noise.cc | 9 ++++ .../shader/nodes/node_shader_uv_along_stroke.cc | 9 ++++ .../nodes/shader/nodes/node_shader_uvmap.cc | 20 +++++++++ .../nodes/shader/nodes/node_shader_vector_math.cc | 9 ++++ .../shader/nodes/node_shader_vector_rotate.cc | 10 +++++ .../shader/nodes/node_shader_vector_transform.cc | 18 +++++++- .../nodes/shader/nodes/node_shader_vertex_color.cc | 26 +++++++++++ .../nodes/shader/nodes/node_shader_wireframe.cc | 9 ++++ 37 files changed, 576 insertions(+), 2 deletions(-) (limited to 'source/blender/nodes/shader') diff --git a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.cc b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.cc index 73f0e515a46..9c64594aab8 100644 --- a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.cc +++ b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.cc @@ -19,6 +19,9 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_ambient_occlusion_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -30,6 +33,15 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("AO")); } +static void node_shader_buts_ambient_occlusion(uiLayout *layout, + bContext *UNUSED(C), + PointerRNA *ptr) +{ + uiItemR(layout, ptr, "samples", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + uiItemR(layout, ptr, "inside", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + uiItemR(layout, ptr, "only_local", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); +} + static int node_shader_gpu_ambient_occlusion(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), @@ -71,6 +83,7 @@ void register_node_type_sh_ambient_occlusion() sh_node_type_base(&ntype, SH_NODE_AMBIENT_OCCLUSION, "Ambient Occlusion", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_ambient_occlusion; node_type_init(&ntype, file_ns::node_shader_init_ambient_occlusion); node_type_gpu(&ntype, file_ns::node_shader_gpu_ambient_occlusion); diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.cc b/source/blender/nodes/shader/nodes/node_shader_attribute.cc index 8cf48306641..cf1b49ba29c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_attribute.cc +++ b/source/blender/nodes/shader/nodes/node_shader_attribute.cc @@ -19,6 +19,9 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_attribute_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -29,6 +32,12 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("Alpha")); } +static void node_shader_buts_attribute(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "attribute_type", UI_ITEM_R_SPLIT_EMPTY_NAME, IFACE_("Type"), ICON_NONE); + uiItemR(layout, ptr, "attribute_name", UI_ITEM_R_SPLIT_EMPTY_NAME, IFACE_("Name"), ICON_NONE); +} + static void node_shader_init_attribute(bNodeTree *UNUSED(ntree), bNode *node) { NodeShaderAttribute *attr = MEM_cnew("NodeShaderAttribute"); @@ -92,6 +101,7 @@ void register_node_type_sh_attribute() sh_node_type_base(&ntype, SH_NODE_ATTRIBUTE, "Attribute", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_attribute; node_type_init(&ntype, file_ns::node_shader_init_attribute); node_type_storage( &ntype, "NodeShaderAttribute", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_bevel.cc b/source/blender/nodes/shader/nodes/node_shader_bevel.cc index aa38eea273c..c4fa61753f5 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bevel.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bevel.cc @@ -19,6 +19,9 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_bevel_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -28,6 +31,11 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("Normal")); } +static void node_shader_buts_bevel(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "samples", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); +} + static void node_shader_init_bevel(bNodeTree *UNUSED(ntree), bNode *node) { node->custom1 = 4; /* samples */ @@ -61,6 +69,7 @@ void register_node_type_sh_bevel() sh_node_type_base(&ntype, SH_NODE_BEVEL, "Bevel", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_bevel; node_type_init(&ntype, file_ns::node_shader_init_bevel); node_type_gpu(&ntype, file_ns::gpu_shader_bevel); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc index 9529edbad0e..3f0749ab2af 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc @@ -19,6 +19,9 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_bsdf_anisotropic_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -40,6 +43,11 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("BSDF")); } +static void node_shader_buts_anisotropic(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "distribution", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); +} + static void node_shader_init_anisotropic(bNodeTree *UNUSED(ntree), bNode *node) { node->custom1 = SHD_GLOSSY_GGX; @@ -79,6 +87,7 @@ void register_node_type_sh_bsdf_anisotropic() sh_node_type_base(&ntype, SH_NODE_BSDF_ANISOTROPIC, "Anisotropic BSDF", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_anisotropic; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, file_ns::node_shader_init_anisotropic); node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_anisotropic); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc index e3de937367d..3be2bd22f60 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc @@ -19,6 +19,9 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_bsdf_hair_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -43,6 +46,11 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("BSDF")); } +static void node_shader_buts_hair(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "component", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); +} + static int node_shader_gpu_bsdf_hair(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), @@ -63,6 +71,7 @@ void register_node_type_sh_bsdf_hair() sh_node_type_base(&ntype, SH_NODE_BSDF_HAIR, "Hair BSDF", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_hair; node_type_size(&ntype, 150, 60, 200); node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_hair); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc index 948ea2ee6e1..7062888b5fb 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc @@ -19,6 +19,9 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_bsdf_hair_principled_cc { /* Color, melanin and absorption coefficient default to approximately same brownish hair. */ @@ -76,6 +79,13 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("BSDF")); } +static void node_shader_buts_principled_hair(uiLayout *layout, + bContext *UNUSED(C), + PointerRNA *ptr) +{ + uiItemR(layout, ptr, "parametrization", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); +} + /* Initialize the custom Parametrization property to Color. */ static void node_shader_init_hair_principled(bNodeTree *UNUSED(ntree), bNode *node) { @@ -126,6 +136,7 @@ void register_node_type_sh_bsdf_hair_principled() sh_node_type_base( &ntype, SH_NODE_BSDF_HAIR_PRINCIPLED, "Principled Hair BSDF", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_principled_hair; node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_init(&ntype, file_ns::node_shader_init_hair_principled); node_type_update(&ntype, file_ns::node_shader_update_hair_principled); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc index 812f582e0dd..4c378d9bc09 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc @@ -19,6 +19,9 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_bsdf_principled_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -119,6 +122,12 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("BSDF")); } +static void node_shader_buts_principled(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "distribution", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); + uiItemR(layout, ptr, "subsurface_method", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); +} + static void node_shader_init_principled(bNodeTree *UNUSED(ntree), bNode *node) { node->custom1 = SHD_GLOSSY_GGX; @@ -240,6 +249,7 @@ void register_node_type_sh_bsdf_principled() sh_node_type_base(&ntype, SH_NODE_BSDF_PRINCIPLED, "Principled BSDF", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_principled; node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_init(&ntype, file_ns::node_shader_init_principled); node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_principled); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc index 80586a5169d..5093b896764 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc @@ -19,6 +19,9 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_bsdf_toon_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -38,6 +41,11 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("BSDF")); } +static void node_shader_buts_toon(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "component", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); +} + static int node_shader_gpu_bsdf_toon(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), @@ -64,6 +72,7 @@ void register_node_type_sh_bsdf_toon() sh_node_type_base(&ntype, SH_NODE_BSDF_TOON, "Toon BSDF", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_toon; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_toon); diff --git a/source/blender/nodes/shader/nodes/node_shader_bump.cc b/source/blender/nodes/shader/nodes/node_shader_bump.cc index 7718b21af52..252abd02ad7 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bump.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bump.cc @@ -23,6 +23,9 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + /* **************** BUMP ******************** */ namespace blender::nodes::node_shader_bump_cc { @@ -46,6 +49,11 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("Normal")); } +static void node_shader_buts_bump(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "invert", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, 0); +} + static int gpu_shader_bump(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), @@ -73,6 +81,7 @@ void register_node_type_sh_bump() sh_node_type_base(&ntype, SH_NODE_BUMP, "Bump", NODE_CLASS_OP_VECTOR); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_bump; node_type_gpu(&ntype, file_ns::gpu_shader_bump); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_clamp.cc b/source/blender/nodes/shader/nodes/node_shader_clamp.cc index f4c72f0616f..4d9cfc372ab 100644 --- a/source/blender/nodes/shader/nodes/node_shader_clamp.cc +++ b/source/blender/nodes/shader/nodes/node_shader_clamp.cc @@ -23,6 +23,9 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_clamp_cc { static void sh_node_clamp_declare(NodeDeclarationBuilder &b) @@ -34,6 +37,11 @@ static void sh_node_clamp_declare(NodeDeclarationBuilder &b) b.add_output(N_("Result")); }; +static void node_shader_buts_clamp(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "clamp_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); +} + static void node_shader_init_clamp(bNodeTree *UNUSED(ntree), bNode *node) { node->custom1 = NODE_CLAMP_MINMAX; /* clamp type */ @@ -83,6 +91,7 @@ void register_node_type_sh_clamp() sh_fn_node_type_base(&ntype, SH_NODE_CLAMP, "Clamp", NODE_CLASS_CONVERTER); ntype.declare = file_ns::sh_node_clamp_declare; + ntype.draw_buttons = file_ns::node_shader_buts_clamp; node_type_init(&ntype, file_ns::node_shader_init_clamp); node_type_gpu(&ntype, file_ns::gpu_shader_clamp); ntype.build_multi_function = file_ns::sh_node_clamp_build_multi_function; diff --git a/source/blender/nodes/shader/nodes/node_shader_ies_light.cc b/source/blender/nodes/shader/nodes/node_shader_ies_light.cc index 481524dadc0..82f0a3045c9 100644 --- a/source/blender/nodes/shader/nodes/node_shader_ies_light.cc +++ b/source/blender/nodes/shader/nodes/node_shader_ies_light.cc @@ -19,6 +19,9 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_ies_light_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -28,6 +31,23 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("Fac")); } +static void node_shader_buts_ies(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiLayout *row; + + row = uiLayoutRow(layout, false); + uiItemR(row, ptr, "mode", UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_EXPAND, nullptr, ICON_NONE); + + row = uiLayoutRow(layout, true); + + if (RNA_enum_get(ptr, "mode") == NODE_IES_INTERNAL) { + uiItemR(row, ptr, "ies", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); + } + else { + uiItemR(row, ptr, "filepath", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); + } +} + static void node_shader_init_tex_ies(bNodeTree *UNUSED(ntree), bNode *node) { NodeShaderTexIES *tex = MEM_cnew("NodeShaderIESLight"); @@ -45,6 +65,7 @@ void register_node_type_sh_tex_ies() sh_node_type_base(&ntype, SH_NODE_TEX_IES, "IES Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_ies; node_type_init(&ntype, file_ns::node_shader_init_tex_ies); node_type_storage( &ntype, "NodeShaderTexIES", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_map_range.cc b/source/blender/nodes/shader/nodes/node_shader_map_range.cc index c4527fd3420..71adf607869 100644 --- a/source/blender/nodes/shader/nodes/node_shader_map_range.cc +++ b/source/blender/nodes/shader/nodes/node_shader_map_range.cc @@ -29,6 +29,9 @@ #include "NOD_socket_search_link.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_map_range_cc { NODE_STORAGE_FUNCS(NodeMapRange) @@ -52,6 +55,17 @@ static void sh_node_map_range_declare(NodeDeclarationBuilder &b) b.add_output(N_("Vector")); }; +static void node_shader_buts_map_range(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "data_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); + uiItemR(layout, ptr, "interpolation_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); + if (!ELEM(RNA_enum_get(ptr, "interpolation_type"), + NODE_MAP_RANGE_SMOOTHSTEP, + NODE_MAP_RANGE_SMOOTHERSTEP)) { + uiItemR(layout, ptr, "clamp", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + } +} + static void node_shader_update_map_range(bNodeTree *ntree, bNode *node) { const NodeMapRange &storage = node_storage(*node); @@ -650,6 +664,7 @@ void register_node_type_sh_map_range() sh_fn_node_type_base(&ntype, SH_NODE_MAP_RANGE, "Map Range", NODE_CLASS_CONVERTER); ntype.declare = file_ns::sh_node_map_range_declare; + ntype.draw_buttons = file_ns::node_shader_buts_map_range; node_type_init(&ntype, file_ns::node_shader_init_map_range); node_type_storage( &ntype, "NodeMapRange", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.cc b/source/blender/nodes/shader/nodes/node_shader_mapping.cc index 4d25ae815d6..19c3a26796e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mapping.cc +++ b/source/blender/nodes/shader/nodes/node_shader_mapping.cc @@ -23,6 +23,9 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_mapping_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -49,6 +52,11 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("Vector")); } +static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "vector_type", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); +} + static const char *gpu_shader_get_name(int mode) { switch (mode) { @@ -94,6 +102,7 @@ void register_node_type_sh_mapping() sh_node_type_base(&ntype, SH_NODE_MAPPING, "Mapping", NODE_CLASS_OP_VECTOR); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_mapping; node_type_gpu(&ntype, file_ns::gpu_shader_mapping); node_type_update(&ntype, file_ns::node_shader_update_mapping); diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.cc b/source/blender/nodes/shader/nodes/node_shader_normal_map.cc index cd99d0a64c9..338b4c62a3a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal_map.cc +++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.cc @@ -19,6 +19,11 @@ #include "node_shader_util.hh" +#include "BKE_context.h" + +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_normal_map_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -28,6 +33,23 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("Normal")); } +static void node_shader_buts_normal_map(uiLayout *layout, bContext *C, PointerRNA *ptr) +{ + uiItemR(layout, ptr, "space", UI_ITEM_R_SPLIT_EMPTY_NAME, "", 0); + + if (RNA_enum_get(ptr, "space") == SHD_SPACE_TANGENT) { + PointerRNA obptr = CTX_data_pointer_get(C, "active_object"); + + if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) { + PointerRNA dataptr = RNA_pointer_get(&obptr, "data"); + uiItemPointerR(layout, ptr, "uv_map", &dataptr, "uv_layers", "", ICON_NONE); + } + else { + uiItemR(layout, ptr, "uv_map", UI_ITEM_R_SPLIT_EMPTY_NAME, "", 0); + } + } +} + static void node_shader_init_normal_map(bNodeTree *UNUSED(ntree), bNode *node) { NodeShaderNormalMap *attr = MEM_cnew("NodeShaderNormalMap"); @@ -113,6 +135,7 @@ void register_node_type_sh_normal_map() sh_node_type_base(&ntype, SH_NODE_NORMAL_MAP, "Normal Map", NODE_CLASS_OP_VECTOR); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_normal_map; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, file_ns::node_shader_init_normal_map); node_type_storage( diff --git a/source/blender/nodes/shader/nodes/node_shader_output_aov.cc b/source/blender/nodes/shader/nodes/node_shader_output_aov.cc index 58a075e9e05..93e1573796f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_aov.cc +++ b/source/blender/nodes/shader/nodes/node_shader_output_aov.cc @@ -21,6 +21,9 @@ #include "BLI_hash.h" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_output_aov_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -29,6 +32,11 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_input(N_("Value")).default_value(0.0f).min(0.0f).max(1.0f); }; +static void node_shader_buts_output_aov(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "name", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); +} + static void node_shader_init_output_aov(bNodeTree *UNUSED(ntree), bNode *node) { NodeShaderOutputAOV *aov = MEM_cnew("NodeShaderOutputAOV"); @@ -63,6 +71,7 @@ void register_node_type_sh_output_aov() sh_node_type_base(&ntype, SH_NODE_OUTPUT_AOV, "AOV Output", NODE_CLASS_OUTPUT); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_output_aov; node_type_init(&ntype, file_ns::node_shader_init_output_aov); node_type_storage( &ntype, "NodeShaderOutputAOV", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_output_linestyle.cc b/source/blender/nodes/shader/nodes/node_shader_output_linestyle.cc index c866b1e336f..ce6771f652f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_linestyle.cc +++ b/source/blender/nodes/shader/nodes/node_shader_output_linestyle.cc @@ -19,6 +19,9 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_output_linestyle_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -41,6 +44,16 @@ static void node_declare(NodeDeclarationBuilder &b) .subtype(PROP_FACTOR); }; +static void node_buts_output_linestyle(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiLayout *row, *col; + + col = uiLayoutColumn(layout, false); + row = uiLayoutRow(col, true); + uiItemR(row, ptr, "blend_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); + uiItemR(col, ptr, "use_clamp", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); +} + } // namespace blender::nodes::node_shader_output_linestyle_cc /* node type definition */ @@ -52,6 +65,7 @@ void register_node_type_sh_output_linestyle() sh_node_type_base(&ntype, SH_NODE_OUTPUT_LINESTYLE, "Line Style Output", NODE_CLASS_OUTPUT); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_buts_output_linestyle; ntype.no_muting = true; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_script.cc b/source/blender/nodes/shader/nodes/node_shader_script.cc index 6c6578cf6c1..e6af90fa588 100644 --- a/source/blender/nodes/shader/nodes/node_shader_script.cc +++ b/source/blender/nodes/shader/nodes/node_shader_script.cc @@ -23,9 +23,42 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_script_cc { -/* **************** Script ******************** */ +static void node_shader_buts_script(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiLayout *row; + + row = uiLayoutRow(layout, false); + uiItemR(row, ptr, "mode", UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_EXPAND, nullptr, ICON_NONE); + + row = uiLayoutRow(layout, true); + + if (RNA_enum_get(ptr, "mode") == NODE_SCRIPT_INTERNAL) { + uiItemR(row, ptr, "script", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); + } + else { + uiItemR(row, ptr, "filepath", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); + } + + uiItemO(row, "", ICON_FILE_REFRESH, "node.shader_script_update"); +} + +static void node_shader_buts_script_ex(uiLayout *layout, bContext *C, PointerRNA *ptr) +{ + uiItemS(layout); + + node_shader_buts_script(layout, C, ptr); + +#if 0 /* not implemented yet */ + if (RNA_enum_get(ptr, "mode") == NODE_SCRIPT_EXTERNAL) { + uiItemR(layout, ptr, "use_auto_update", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + } +#endif +} static void init(bNodeTree *UNUSED(ntree), bNode *node) { @@ -69,6 +102,8 @@ void register_node_type_sh_script() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_SCRIPT, "Script", NODE_CLASS_SCRIPT); + ntype.draw_buttons = file_ns::node_shader_buts_script; + ntype.draw_buttons_ex = file_ns::node_shader_buts_script_ex; node_type_init(&ntype, file_ns::init); node_type_storage( &ntype, "NodeShaderScript", file_ns::node_free_script, file_ns::node_copy_script); diff --git a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc index 5f02fe54745..f60db81b4a9 100644 --- a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc +++ b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc @@ -19,6 +19,9 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_subsurface_scattering_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -41,6 +44,11 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("BSSRDF")); } +static void node_shader_buts_subsurface(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "falloff", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); +} + static void node_shader_init_subsurface_scattering(bNodeTree *UNUSED(ntree), bNode *node) { node->custom1 = SHD_SUBSURFACE_RANDOM_WALK; @@ -95,6 +103,7 @@ void register_node_type_sh_subsurface_scattering() sh_node_type_base( &ntype, SH_NODE_SUBSURFACE_SCATTERING, "Subsurface Scattering", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_subsurface; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, file_ns::node_shader_init_subsurface_scattering); node_type_gpu(&ntype, file_ns::node_shader_gpu_subsurface_scattering); diff --git a/source/blender/nodes/shader/nodes/node_shader_tangent.cc b/source/blender/nodes/shader/nodes/node_shader_tangent.cc index 55eec96ce81..fb5637648f7 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tangent.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tangent.cc @@ -19,6 +19,11 @@ #include "node_shader_util.hh" +#include "BKE_context.h" + +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_tangent_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -26,6 +31,32 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("Tangent")); }; +static void node_shader_buts_tangent(uiLayout *layout, bContext *C, PointerRNA *ptr) +{ + uiLayout *split, *row; + + split = uiLayoutSplit(layout, 0.0f, false); + + uiItemR(split, ptr, "direction_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", 0); + + row = uiLayoutRow(split, false); + + if (RNA_enum_get(ptr, "direction_type") == SHD_TANGENT_UVMAP) { + PointerRNA obptr = CTX_data_pointer_get(C, "active_object"); + + if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) { + PointerRNA dataptr = RNA_pointer_get(&obptr, "data"); + uiItemPointerR(row, ptr, "uv_map", &dataptr, "uv_layers", "", ICON_NONE); + } + else { + uiItemR(row, ptr, "uv_map", UI_ITEM_R_SPLIT_EMPTY_NAME, "", 0); + } + } + else { + uiItemR(row, ptr, "axis", UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_EXPAND, nullptr, 0); + } +} + static void node_shader_init_tangent(bNodeTree *UNUSED(ntree), bNode *node) { NodeShaderTangent *attr = MEM_cnew("NodeShaderTangent"); @@ -79,6 +110,7 @@ void register_node_type_sh_tangent() sh_node_type_base(&ntype, SH_NODE_TANGENT, "Tangent", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_tangent; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, file_ns::node_shader_init_tangent); node_type_gpu(&ntype, file_ns::node_shader_gpu_tangent); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc b/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc index 6a4a131a315..b8cb00a6487 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc @@ -22,6 +22,9 @@ #include "BLI_float2.hh" #include "BLI_float4.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_tex_brick_cc { static void sh_node_tex_brick_declare(NodeDeclarationBuilder &b) @@ -57,6 +60,26 @@ static void sh_node_tex_brick_declare(NodeDeclarationBuilder &b) b.add_output(N_("Fac")); }; +static void node_shader_buts_tex_brick(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiLayout *col; + + col = uiLayoutColumn(layout, true); + uiItemR(col, + ptr, + "offset", + UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_SLIDER, + IFACE_("Offset"), + ICON_NONE); + uiItemR( + col, ptr, "offset_frequency", UI_ITEM_R_SPLIT_EMPTY_NAME, IFACE_("Frequency"), ICON_NONE); + + col = uiLayoutColumn(layout, true); + uiItemR(col, ptr, "squash", UI_ITEM_R_SPLIT_EMPTY_NAME, IFACE_("Squash"), ICON_NONE); + uiItemR( + col, ptr, "squash_frequency", UI_ITEM_R_SPLIT_EMPTY_NAME, IFACE_("Frequency"), ICON_NONE); +} + static void node_shader_init_tex_brick(bNodeTree *UNUSED(ntree), bNode *node) { NodeTexBrick *tex = MEM_cnew(__func__); @@ -272,6 +295,7 @@ void register_node_type_sh_tex_brick() sh_fn_node_type_base(&ntype, SH_NODE_TEX_BRICK, "Brick Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::sh_node_tex_brick_declare; + ntype.draw_buttons = file_ns::node_shader_buts_tex_brick; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, file_ns::node_shader_init_tex_brick); node_type_storage( diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc b/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc index 31f85441a80..1bbaed88ea5 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc @@ -21,6 +21,9 @@ #include "DNA_customdata_types.h" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_tex_coord_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -34,6 +37,12 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("Reflection")); } +static void node_shader_buts_tex_coord(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "object", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, 0); + uiItemR(layout, ptr, "from_instancer", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, 0); +} + static int node_shader_gpu_tex_coord(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), @@ -94,6 +103,7 @@ void register_node_type_sh_tex_coord() sh_node_type_base(&ntype, SH_NODE_TEX_COORD, "Texture Coordinate", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_tex_coord; node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_coord); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc index 2f47f214681..352cde0b947 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc @@ -19,6 +19,9 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_tex_gradient_cc { static void sh_node_tex_gradient_declare(NodeDeclarationBuilder &b) @@ -29,6 +32,11 @@ static void sh_node_tex_gradient_declare(NodeDeclarationBuilder &b) b.add_output(N_("Fac")).no_muted_links(); }; +static void node_shader_buts_tex_gradient(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "gradient_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); +} + static void node_shader_init_tex_gradient(bNodeTree *UNUSED(ntree), bNode *node) { NodeTexGradient *tex = MEM_cnew(__func__); @@ -163,6 +171,7 @@ void register_node_type_sh_tex_gradient() sh_fn_node_type_base(&ntype, SH_NODE_TEX_GRADIENT, "Gradient Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::sh_node_tex_gradient_declare; + ntype.draw_buttons = file_ns::node_shader_buts_tex_gradient; node_type_init(&ntype, file_ns::node_shader_init_tex_gradient); node_type_storage( &ntype, "NodeTexGradient", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_magic.cc b/source/blender/nodes/shader/nodes/node_shader_tex_magic.cc index b388f1a3172..22a0532b57b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_magic.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_magic.cc @@ -19,6 +19,9 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_tex_magic_cc { static void sh_node_tex_magic_declare(NodeDeclarationBuilder &b) @@ -31,6 +34,11 @@ static void sh_node_tex_magic_declare(NodeDeclarationBuilder &b) b.add_output(N_("Fac")).no_muted_links(); }; +static void node_shader_buts_tex_magic(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "turbulence_depth", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); +} + static void node_shader_init_tex_magic(bNodeTree *UNUSED(ntree), bNode *node) { NodeTexMagic *tex = MEM_cnew(__func__); @@ -185,6 +193,7 @@ void register_node_type_sh_tex_magic() sh_fn_node_type_base(&ntype, SH_NODE_TEX_MAGIC, "Magic Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::sh_node_tex_magic_declare; + ntype.draw_buttons = file_ns::node_shader_buts_tex_magic; node_type_init(&ntype, file_ns::node_shader_init_tex_magic); node_type_storage( &ntype, "NodeTexMagic", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc index 94713ad24ba..52ab70848de 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc @@ -21,6 +21,9 @@ #include "BLI_noise.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_tex_musgrave_cc { NODE_STORAGE_FUNCS(NodeTexMusgrave) @@ -42,6 +45,12 @@ static void sh_node_tex_musgrave_declare(NodeDeclarationBuilder &b) b.add_output(N_("Fac")).no_muted_links(); }; +static void node_shader_buts_tex_musgrave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "musgrave_dimensions", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); + uiItemR(layout, ptr, "musgrave_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); +} + static void node_shader_init_tex_musgrave(bNodeTree *UNUSED(ntree), bNode *node) { NodeTexMusgrave *tex = MEM_cnew(__func__); @@ -539,6 +548,7 @@ void register_node_type_sh_tex_musgrave() sh_fn_node_type_base(&ntype, SH_NODE_TEX_MUSGRAVE, "Musgrave Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::sh_node_tex_musgrave_declare; + ntype.draw_buttons = file_ns::node_shader_buts_tex_musgrave; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, file_ns::node_shader_init_tex_musgrave); node_type_storage( 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 fe402675ec6..9e378ff0110 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc @@ -21,6 +21,9 @@ #include "BLI_noise.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_tex_noise_cc { NODE_STORAGE_FUNCS(NodeTexNoise) @@ -45,6 +48,11 @@ static void sh_node_tex_noise_declare(NodeDeclarationBuilder &b) b.add_output(N_("Color")).no_muted_links(); }; +static void node_shader_buts_tex_noise(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "noise_dimensions", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); +} + static void node_shader_init_tex_noise(bNodeTree *UNUSED(ntree), bNode *node) { NodeTexNoise *tex = MEM_cnew(__func__); @@ -256,6 +264,7 @@ void register_node_type_sh_tex_noise() sh_fn_node_type_base(&ntype, SH_NODE_TEX_NOISE, "Noise Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::sh_node_tex_noise_declare; + ntype.draw_buttons = file_ns::node_shader_buts_tex_noise; node_type_init(&ntype, file_ns::node_shader_init_tex_noise); node_type_storage( &ntype, "NodeTexNoise", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.cc b/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.cc index 8a42577d35c..1a4cf70565f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.cc @@ -21,6 +21,9 @@ #include "RE_texture.h" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_tex_pointdensity_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -30,6 +33,52 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("Density")); } +static void node_shader_buts_tex_pointdensity(uiLayout *layout, + bContext *UNUSED(C), + PointerRNA *ptr) +{ + bNode *node = (bNode *)ptr->data; + NodeShaderTexPointDensity *shader_point_density = (NodeShaderTexPointDensity *)node->storage; + Object *ob = (Object *)node->id; + + PointerRNA ob_ptr, obdata_ptr; + RNA_id_pointer_create((ID *)ob, &ob_ptr); + RNA_id_pointer_create(ob ? (ID *)ob->data : nullptr, &obdata_ptr); + + uiItemR(layout, ptr, "point_source", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); + uiItemR(layout, ptr, "object", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + + if (node->id && shader_point_density->point_source == SHD_POINTDENSITY_SOURCE_PSYS) { + PointerRNA dataptr; + RNA_id_pointer_create((ID *)node->id, &dataptr); + uiItemPointerR( + layout, ptr, "particle_system", &dataptr, "particle_systems", nullptr, ICON_NONE); + } + + uiItemR(layout, ptr, "space", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + uiItemR(layout, ptr, "radius", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + uiItemR(layout, ptr, "interpolation", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + uiItemR(layout, ptr, "resolution", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + if (shader_point_density->point_source == SHD_POINTDENSITY_SOURCE_PSYS) { + uiItemR(layout, ptr, "particle_color_source", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + } + else { + uiItemR(layout, ptr, "vertex_color_source", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + if (shader_point_density->ob_color_source == SHD_POINTDENSITY_COLOR_VERTWEIGHT) { + if (ob_ptr.data) { + uiItemPointerR( + layout, ptr, "vertex_attribute_name", &ob_ptr, "vertex_groups", "", ICON_NONE); + } + } + if (shader_point_density->ob_color_source == SHD_POINTDENSITY_COLOR_VERTCOL) { + if (obdata_ptr.data) { + uiItemPointerR( + layout, ptr, "vertex_attribute_name", &obdata_ptr, "vertex_colors", "", ICON_NONE); + } + } + } +} + static void node_shader_init_tex_pointdensity(bNodeTree *UNUSED(ntree), bNode *node) { NodeShaderTexPointDensity *point_density = MEM_cnew("new pd node"); @@ -71,6 +120,7 @@ void register_node_type_sh_tex_pointdensity() sh_node_type_base(&ntype, SH_NODE_TEX_POINTDENSITY, "Point Density", NODE_CLASS_TEXTURE); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_tex_pointdensity; node_type_init(&ntype, file_ns::node_shader_init_tex_pointdensity); node_type_storage(&ntype, "NodeShaderTexPointDensity", diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc b/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc index 209d71db1ff..b8728d69bba 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc @@ -20,6 +20,12 @@ #include "node_shader_util.hh" #include "sky_model.h" +#include "BKE_context.h" +#include "BKE_scene.h" + +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_tex_sky_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -28,6 +34,46 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("Color")).no_muted_links(); } +static void node_shader_buts_tex_sky(uiLayout *layout, bContext *C, PointerRNA *ptr) +{ + uiItemR(layout, ptr, "sky_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); + + if (RNA_enum_get(ptr, "sky_type") == SHD_SKY_PREETHAM) { + uiItemR(layout, ptr, "sun_direction", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); + uiItemR(layout, ptr, "turbidity", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + } + if (RNA_enum_get(ptr, "sky_type") == SHD_SKY_HOSEK) { + uiItemR(layout, ptr, "sun_direction", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); + uiItemR(layout, ptr, "turbidity", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + uiItemR(layout, ptr, "ground_albedo", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + } + if (RNA_enum_get(ptr, "sky_type") == SHD_SKY_NISHITA) { + Scene *scene = CTX_data_scene(C); + if (BKE_scene_uses_blender_eevee(scene)) { + uiItemL(layout, TIP_("Nishita not available in Eevee"), ICON_ERROR); + } + uiItemR(layout, ptr, "sun_disc", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, 0); + + uiLayout *col; + if (RNA_boolean_get(ptr, "sun_disc")) { + col = uiLayoutColumn(layout, true); + uiItemR(col, ptr, "sun_size", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + uiItemR(col, ptr, "sun_intensity", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + } + + col = uiLayoutColumn(layout, true); + uiItemR(col, ptr, "sun_elevation", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + uiItemR(col, ptr, "sun_rotation", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + + uiItemR(layout, ptr, "altitude", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + + col = uiLayoutColumn(layout, true); + uiItemR(col, ptr, "air_density", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + uiItemR(col, ptr, "dust_density", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + uiItemR(col, ptr, "ozone_density", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + } +} + static void node_shader_init_tex_sky(bNodeTree *UNUSED(ntree), bNode *node) { NodeTexSky *tex = MEM_cnew("NodeTexSky"); @@ -210,6 +256,7 @@ void register_node_type_sh_tex_sky() sh_node_type_base(&ntype, SH_NODE_TEX_SKY, "Sky Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_tex_sky; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, file_ns::node_shader_init_tex_sky); node_type_storage(&ntype, "NodeTexSky", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc index 72f7fe08a15..22f02fecffd 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc @@ -21,6 +21,9 @@ #include "BLI_noise.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_tex_voronoi_cc { NODE_STORAGE_FUNCS(NodeTexVoronoi) @@ -62,6 +65,17 @@ static void sh_node_tex_voronoi_declare(NodeDeclarationBuilder &b) }); }; +static void node_shader_buts_tex_voronoi(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "voronoi_dimensions", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); + uiItemR(layout, ptr, "feature", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); + int feature = RNA_enum_get(ptr, "feature"); + if (!ELEM(feature, SHD_VORONOI_DISTANCE_TO_EDGE, SHD_VORONOI_N_SPHERE_RADIUS) && + RNA_enum_get(ptr, "voronoi_dimensions") != 1) { + uiItemR(layout, ptr, "distance", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); + } +} + static void node_shader_init_tex_voronoi(bNodeTree *UNUSED(ntree), bNode *node) { NodeTexVoronoi *tex = MEM_cnew(__func__); @@ -1346,6 +1360,7 @@ void register_node_type_sh_tex_voronoi() sh_fn_node_type_base(&ntype, SH_NODE_TEX_VORONOI, "Voronoi Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::sh_node_tex_voronoi_declare; + ntype.draw_buttons = file_ns::node_shader_buts_tex_voronoi; node_type_init(&ntype, file_ns::node_shader_init_tex_voronoi); node_type_storage( &ntype, "NodeTexVoronoi", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_wave.cc b/source/blender/nodes/shader/nodes/node_shader_tex_wave.cc index 9a3e214333b..1216614a8ef 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_wave.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_wave.cc @@ -21,6 +21,9 @@ #include "BLI_noise.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_tex_wave_cc { static void sh_node_tex_wave_declare(NodeDeclarationBuilder &b) @@ -41,6 +44,20 @@ static void sh_node_tex_wave_declare(NodeDeclarationBuilder &b) b.add_output(N_("Fac")).no_muted_links(); }; +static void node_shader_buts_tex_wave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "wave_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); + int type = RNA_enum_get(ptr, "wave_type"); + if (type == SHD_WAVE_BANDS) { + uiItemR(layout, ptr, "bands_direction", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); + } + else { /* SHD_WAVE_RINGS */ + uiItemR(layout, ptr, "rings_direction", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); + } + + uiItemR(layout, ptr, "wave_profile", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); +} + static void node_shader_init_tex_wave(bNodeTree *UNUSED(ntree), bNode *node) { NodeTexWave *tex = MEM_cnew(__func__); @@ -222,6 +239,7 @@ void register_node_type_sh_tex_wave() sh_fn_node_type_base(&ntype, SH_NODE_TEX_WAVE, "Wave Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::sh_node_tex_wave_declare; + ntype.draw_buttons = file_ns::node_shader_buts_tex_wave; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, file_ns::node_shader_init_tex_wave); node_type_storage(&ntype, "NodeTexWave", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc b/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc index 96d45d7c53b..49bf622e2a5 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc @@ -21,6 +21,9 @@ #include "BLI_noise.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_tex_white_noise_cc { static void sh_node_tex_white_noise_declare(NodeDeclarationBuilder &b) @@ -35,6 +38,11 @@ static void sh_node_tex_white_noise_declare(NodeDeclarationBuilder &b) b.add_output(N_("Color")); }; +static void node_shader_buts_white_noise(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "noise_dimensions", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); +} + static void node_shader_init_tex_white_noise(bNodeTree *UNUSED(ntree), bNode *node) { node->custom1 = 3; @@ -198,6 +206,7 @@ void register_node_type_sh_tex_white_noise() sh_fn_node_type_base(&ntype, SH_NODE_TEX_WHITE_NOISE, "White Noise Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::sh_node_tex_white_noise_declare; + ntype.draw_buttons = file_ns::node_shader_buts_white_noise; node_type_init(&ntype, file_ns::node_shader_init_tex_white_noise); node_type_gpu(&ntype, file_ns::gpu_shader_tex_white_noise); node_type_update(&ntype, file_ns::node_shader_update_tex_white_noise); diff --git a/source/blender/nodes/shader/nodes/node_shader_uv_along_stroke.cc b/source/blender/nodes/shader/nodes/node_shader_uv_along_stroke.cc index 18bea5c1ec6..382a0f16ecd 100644 --- a/source/blender/nodes/shader/nodes/node_shader_uv_along_stroke.cc +++ b/source/blender/nodes/shader/nodes/node_shader_uv_along_stroke.cc @@ -19,6 +19,9 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_uv_along_stroke_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -26,6 +29,11 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("UV")); } +static void node_shader_buts_uvalongstroke(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "use_tips", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, 0); +} + } // namespace blender::nodes::node_shader_uv_along_stroke_cc /* node type definition */ @@ -37,6 +45,7 @@ void register_node_type_sh_uvalongstroke() sh_node_type_base(&ntype, SH_NODE_UVALONGSTROKE, "UV Along Stroke", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_uvalongstroke; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_uvmap.cc b/source/blender/nodes/shader/nodes/node_shader_uvmap.cc index 70fde996dc3..b004be75188 100644 --- a/source/blender/nodes/shader/nodes/node_shader_uvmap.cc +++ b/source/blender/nodes/shader/nodes/node_shader_uvmap.cc @@ -19,8 +19,13 @@ #include "node_shader_util.hh" +#include "BKE_context.h" + #include "DNA_customdata_types.h" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_uvmap_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -28,6 +33,20 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("UV")); } +static void node_shader_buts_uvmap(uiLayout *layout, bContext *C, PointerRNA *ptr) +{ + uiItemR(layout, ptr, "from_instancer", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, 0); + + if (!RNA_boolean_get(ptr, "from_instancer")) { + PointerRNA obptr = CTX_data_pointer_get(C, "active_object"); + + if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) { + PointerRNA dataptr = RNA_pointer_get(&obptr, "data"); + uiItemPointerR(layout, ptr, "uv_map", &dataptr, "uv_layers", "", ICON_NONE); + } + } +} + static void node_shader_init_uvmap(bNodeTree *UNUSED(ntree), bNode *node) { NodeShaderUVMap *attr = MEM_cnew("NodeShaderUVMap"); @@ -61,6 +80,7 @@ void register_node_type_sh_uvmap() sh_node_type_base(&ntype, SH_NODE_UVMAP, "UV Map", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_uvmap; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_init(&ntype, file_ns::node_shader_init_uvmap); node_type_storage( diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc index 1276592e2af..1fa4d712d27 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc @@ -28,6 +28,9 @@ #include "RNA_enum_types.h" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_vector_math_cc { static void sh_node_vector_math_declare(NodeDeclarationBuilder &b) @@ -41,6 +44,11 @@ static void sh_node_vector_math_declare(NodeDeclarationBuilder &b) b.add_output(N_("Value")); }; +static void node_shader_buts_vect_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "operation", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); +} + class SocketSearchOp { public: std::string socket_name; @@ -331,6 +339,7 @@ void register_node_type_sh_vect_math() sh_fn_node_type_base(&ntype, SH_NODE_VECTOR_MATH, "Vector Math", NODE_CLASS_OP_VECTOR); ntype.declare = file_ns::sh_node_vector_math_declare; + ntype.draw_buttons = file_ns::node_shader_buts_vect_math; ntype.labelfunc = node_vector_math_label; node_type_gpu(&ntype, file_ns::gpu_shader_vector_math); node_type_update(&ntype, file_ns::node_shader_update_vector_math); diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc b/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc index bb7a81ef5d8..a59d3039e4e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc @@ -23,6 +23,9 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_vector_rotate_cc { static void sh_node_vector_rotate_declare(NodeDeclarationBuilder &b) @@ -36,6 +39,12 @@ static void sh_node_vector_rotate_declare(NodeDeclarationBuilder &b) b.add_output(N_("Vector")); }; +static void node_shader_buts_vector_rotate(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "rotation_type", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); + uiItemR(layout, ptr, "invert", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, 0); +} + static const char *gpu_shader_get_name(int mode) { switch (mode) { @@ -213,6 +222,7 @@ void register_node_type_sh_vector_rotate() sh_fn_node_type_base(&ntype, SH_NODE_VECTOR_ROTATE, "Vector Rotate", NODE_CLASS_OP_VECTOR); ntype.declare = file_ns::sh_node_vector_rotate_declare; + ntype.draw_buttons = file_ns::node_shader_buts_vector_rotate; node_type_gpu(&ntype, file_ns::gpu_shader_vector_rotate); node_type_update(&ntype, file_ns::node_shader_update_vector_rotate); ntype.build_multi_function = file_ns::sh_node_vector_rotate_build_multi_function; diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc b/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc index d5960910042..a8a6902e30c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc @@ -23,6 +23,9 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_vector_transform_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -34,6 +37,18 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("Vector")); } +static void node_shader_buts_vect_transform(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, + ptr, + "vector_type", + UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_EXPAND, + nullptr, + ICON_NONE); + uiItemR(layout, ptr, "convert_from", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); + uiItemR(layout, ptr, "convert_to", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); +} + static void node_shader_init_vect_transform(bNodeTree *UNUSED(ntree), bNode *node) { NodeShaderVectTransform *vect = MEM_cnew("NodeShaderVectTransform"); @@ -138,8 +153,9 @@ void register_node_type_sh_vect_transform() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_VECT_TRANSFORM, "Vector Transform", NODE_CLASS_OP_VECTOR); - node_type_init(&ntype, file_ns::node_shader_init_vect_transform); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_vect_transform; + node_type_init(&ntype, file_ns::node_shader_init_vect_transform); node_type_storage( &ntype, "NodeShaderVectTransform", node_free_standard_storage, node_copy_standard_storage); node_type_gpu(&ntype, file_ns::gpu_shader_vect_transform); diff --git a/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc b/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc index 0d3f047f54e..6501527ef5d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc @@ -19,6 +19,11 @@ #include "node_shader_util.hh" +#include "BKE_context.h" + +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_vertex_color_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -27,6 +32,26 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("Alpha")); } +static void node_shader_buts_vertex_color(uiLayout *layout, bContext *C, PointerRNA *ptr) +{ + PointerRNA obptr = CTX_data_pointer_get(C, "active_object"); + if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) { + PointerRNA dataptr = RNA_pointer_get(&obptr, "data"); + + if (U.experimental.use_sculpt_vertex_colors && + RNA_collection_length(&dataptr, "sculpt_vertex_colors")) { + uiItemPointerR( + layout, ptr, "layer_name", &dataptr, "sculpt_vertex_colors", "", ICON_GROUP_VCOL); + } + else { + uiItemPointerR(layout, ptr, "layer_name", &dataptr, "vertex_colors", "", ICON_GROUP_VCOL); + } + } + else { + uiItemL(layout, TIP_("No mesh in active object"), ICON_ERROR); + } +} + static void node_shader_init_vertex_color(bNodeTree *UNUSED(ntree), bNode *node) { NodeShaderVertexColor *vertexColor = MEM_cnew("NodeShaderVertexColor"); @@ -58,6 +83,7 @@ void register_node_type_sh_vertex_color() sh_node_type_base(&ntype, SH_NODE_VERTEX_COLOR, "Vertex Color", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_vertex_color; node_type_init(&ntype, file_ns::node_shader_init_vertex_color); node_type_storage( &ntype, "NodeShaderVertexColor", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_wireframe.cc b/source/blender/nodes/shader/nodes/node_shader_wireframe.cc index a23887e9721..1ba2391a09d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_wireframe.cc +++ b/source/blender/nodes/shader/nodes/node_shader_wireframe.cc @@ -19,6 +19,9 @@ #include "node_shader_util.hh" +#include "UI_interface.h" +#include "UI_resources.h" + namespace blender::nodes::node_shader_wireframe_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -27,6 +30,11 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("Fac")); } +static void node_shader_buts_wireframe(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "use_pixel_size", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, 0); +} + static int node_shader_gpu_wireframe(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), @@ -60,6 +68,7 @@ void register_node_type_sh_wireframe() sh_node_type_base(&ntype, SH_NODE_WIREFRAME, "Wireframe", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; + ntype.draw_buttons = file_ns::node_shader_buts_wireframe; node_type_gpu(&ntype, file_ns::node_shader_gpu_wireframe); nodeRegisterType(&ntype); -- cgit v1.2.3 From 6110f3aa1f4df2f477c88cbe6f57747f3ea2717a Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Sun, 9 Jan 2022 17:44:36 -0500 Subject: Cleanup: Use new socket builder API --- .../nodes/shader/nodes/node_shader_normal.cc | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'source/blender/nodes/shader') diff --git a/source/blender/nodes/shader/nodes/node_shader_normal.cc b/source/blender/nodes/shader/nodes/node_shader_normal.cc index d6caa4219f9..e677f36e425 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal.cc +++ b/source/blender/nodes/shader/nodes/node_shader_normal.cc @@ -25,17 +25,20 @@ namespace blender::nodes::node_shader_normal_cc { -/* **************** NORMAL ******************** */ -static bNodeSocketTemplate sh_node_normal_in[] = { - {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 1.0f, PROP_DIRECTION}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_normal_out[] = { - {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 1.0f, PROP_DIRECTION}, - {SOCK_FLOAT, N_("Dot")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input(N_("Normal")) + .default_value({0.0f, 0.0f, 1.0f}) + .min(-1.0f) + .max(1.0f) + .subtype(PROP_DIRECTION); + b.add_output(N_("Normal")) + .default_value({0.0f, 0.0f, 1.0f}) + .min(-1.0f) + .max(1.0f) + .subtype(PROP_DIRECTION); + b.add_output(N_("Dot")); +} static int gpu_shader_normal(GPUMaterial *mat, bNode *node, @@ -56,7 +59,7 @@ void register_node_type_sh_normal() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_NORMAL, "Normal", NODE_CLASS_OP_VECTOR); - node_type_socket_templates(&ntype, file_ns::sh_node_normal_in, file_ns::sh_node_normal_out); + ntype.declare = file_ns::node_declare; node_type_gpu(&ntype, file_ns::gpu_shader_normal); nodeRegisterType(&ntype); -- cgit v1.2.3 From 17c7bac4052e1b5061d0cfdee5096d5e30837cc2 Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Sun, 9 Jan 2022 18:24:48 -0500 Subject: Cleanup: redundent semicolons after function braces --- source/blender/nodes/shader/nodes/node_shader_clamp.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_color_ramp.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_curves.cc | 6 +++--- source/blender/nodes/shader/nodes/node_shader_map_range.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_math.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_mix_rgb.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_mix_shader.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_output_aov.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_output_light.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_output_linestyle.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_output_material.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_output_world.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_particle_info.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_rgb_to_bw.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_sepcomb_rgb.cc | 4 ++-- source/blender/nodes/shader/nodes/node_shader_sepcomb_xyz.cc | 4 ++-- source/blender/nodes/shader/nodes/node_shader_shader_to_rgb.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_tangent.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_tex_brick.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_tex_checker.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_tex_image.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_tex_magic.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_tex_noise.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_tex_wave.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_value.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_vector_math.cc | 2 +- source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc | 2 +- 31 files changed, 35 insertions(+), 35 deletions(-) (limited to 'source/blender/nodes/shader') diff --git a/source/blender/nodes/shader/nodes/node_shader_clamp.cc b/source/blender/nodes/shader/nodes/node_shader_clamp.cc index 4d9cfc372ab..cd0f1b3c44d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_clamp.cc +++ b/source/blender/nodes/shader/nodes/node_shader_clamp.cc @@ -35,7 +35,7 @@ static void sh_node_clamp_declare(NodeDeclarationBuilder &b) b.add_input(N_("Min")).default_value(0.0f).min(-10000.0f).max(10000.0f); b.add_input(N_("Max")).default_value(1.0f).min(-10000.0f).max(10000.0f); b.add_output(N_("Result")); -}; +} static void node_shader_buts_clamp(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { diff --git a/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc b/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc index 353cbf4ca15..d8c43e1d66b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc +++ b/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc @@ -35,7 +35,7 @@ static void sh_node_valtorgb_declare(NodeDeclarationBuilder &b) b.add_input(N_("Fac")).default_value(0.5f).min(0.0f).max(1.0f).subtype(PROP_FACTOR); b.add_output(N_("Color")); b.add_output(N_("Alpha")); -}; +} static void node_shader_init_valtorgb(bNodeTree *UNUSED(ntree), bNode *node) { diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.cc b/source/blender/nodes/shader/nodes/node_shader_curves.cc index 67095561caf..bce59a60033 100644 --- a/source/blender/nodes/shader/nodes/node_shader_curves.cc +++ b/source/blender/nodes/shader/nodes/node_shader_curves.cc @@ -31,7 +31,7 @@ static void sh_node_curve_vec_declare(NodeDeclarationBuilder &b) b.add_input(N_("Fac")).min(0.0f).max(1.0f).default_value(1.0f).subtype(PROP_FACTOR); b.add_input(N_("Vector")).min(-1.0f).max(1.0f); b.add_output(N_("Vector")); -}; +} static void node_shader_init_curve_vec(bNodeTree *UNUSED(ntree), bNode *node) { @@ -164,7 +164,7 @@ static void sh_node_curve_rgb_declare(NodeDeclarationBuilder &b) b.add_input(N_("Fac")).min(0.0f).max(1.0f).default_value(1.0f).subtype(PROP_FACTOR); b.add_input(N_("Color")).default_value({1.0f, 1.0f, 1.0f, 1.0f}); b.add_output(N_("Color")); -}; +} static void node_shader_init_curve_rgb(bNodeTree *UNUSED(ntree), bNode *node) { @@ -326,7 +326,7 @@ static void sh_node_curve_float_declare(NodeDeclarationBuilder &b) .subtype(PROP_FACTOR); b.add_input(N_("Value")).default_value(1.0f).is_default_link_socket(); b.add_output(N_("Value")); -}; +} static void node_shader_init_curve_float(bNodeTree *UNUSED(ntree), bNode *node) { diff --git a/source/blender/nodes/shader/nodes/node_shader_map_range.cc b/source/blender/nodes/shader/nodes/node_shader_map_range.cc index 71adf607869..3276a1bfd72 100644 --- a/source/blender/nodes/shader/nodes/node_shader_map_range.cc +++ b/source/blender/nodes/shader/nodes/node_shader_map_range.cc @@ -53,7 +53,7 @@ static void sh_node_map_range_declare(NodeDeclarationBuilder &b) b.add_input(N_("Steps"), "Steps_FLOAT3").default_value(float3(4.0f)); b.add_output(N_("Result")); b.add_output(N_("Vector")); -}; +} static void node_shader_buts_map_range(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { diff --git a/source/blender/nodes/shader/nodes/node_shader_math.cc b/source/blender/nodes/shader/nodes/node_shader_math.cc index ca30b16f7ff..50585405cbf 100644 --- a/source/blender/nodes/shader/nodes/node_shader_math.cc +++ b/source/blender/nodes/shader/nodes/node_shader_math.cc @@ -45,7 +45,7 @@ static void sh_node_math_declare(NodeDeclarationBuilder &b) .min(-10000.0f) .max(10000.0f); b.add_output(N_("Value")); -}; +} class SocketSearchOp { public: diff --git a/source/blender/nodes/shader/nodes/node_shader_mix_rgb.cc b/source/blender/nodes/shader/nodes/node_shader_mix_rgb.cc index 7f9dc8424cf..9678e86d289 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mix_rgb.cc +++ b/source/blender/nodes/shader/nodes/node_shader_mix_rgb.cc @@ -32,7 +32,7 @@ static void sh_node_mix_rgb_declare(NodeDeclarationBuilder &b) b.add_input(N_("Color1")).default_value({0.5f, 0.5f, 0.5f, 1.0f}); b.add_input(N_("Color2")).default_value({0.5f, 0.5f, 0.5f, 1.0f}); b.add_output(N_("Color")); -}; +} static const char *gpu_shader_get_name(int mode) { diff --git a/source/blender/nodes/shader/nodes/node_shader_mix_shader.cc b/source/blender/nodes/shader/nodes/node_shader_mix_shader.cc index c320fafa2ef..d9aa906e451 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mix_shader.cc +++ b/source/blender/nodes/shader/nodes/node_shader_mix_shader.cc @@ -27,7 +27,7 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_input(N_("Shader")); b.add_input(N_("Shader"), "Shader_001"); b.add_output(N_("Shader")); -}; +} static int node_shader_gpu_mix_shader(GPUMaterial *mat, bNode *node, diff --git a/source/blender/nodes/shader/nodes/node_shader_output_aov.cc b/source/blender/nodes/shader/nodes/node_shader_output_aov.cc index 93e1573796f..6ffd763b0d1 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_aov.cc +++ b/source/blender/nodes/shader/nodes/node_shader_output_aov.cc @@ -30,7 +30,7 @@ static void node_declare(NodeDeclarationBuilder &b) { b.add_input(N_("Color")).default_value({0.0f, 0.0f, 0.0f, 1.0f}); b.add_input(N_("Value")).default_value(0.0f).min(0.0f).max(1.0f); -}; +} static void node_shader_buts_output_aov(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { diff --git a/source/blender/nodes/shader/nodes/node_shader_output_light.cc b/source/blender/nodes/shader/nodes/node_shader_output_light.cc index 05eec40e020..0c8288f801b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_light.cc +++ b/source/blender/nodes/shader/nodes/node_shader_output_light.cc @@ -24,7 +24,7 @@ namespace blender::nodes::node_shader_output_light_cc { static void node_declare(NodeDeclarationBuilder &b) { b.add_input(N_("Surface")); -}; +} } // namespace blender::nodes::node_shader_output_light_cc diff --git a/source/blender/nodes/shader/nodes/node_shader_output_linestyle.cc b/source/blender/nodes/shader/nodes/node_shader_output_linestyle.cc index ce6771f652f..9b6c3292e75 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_linestyle.cc +++ b/source/blender/nodes/shader/nodes/node_shader_output_linestyle.cc @@ -42,7 +42,7 @@ static void node_declare(NodeDeclarationBuilder &b) .min(0.0f) .max(1.0f) .subtype(PROP_FACTOR); -}; +} static void node_buts_output_linestyle(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { diff --git a/source/blender/nodes/shader/nodes/node_shader_output_material.cc b/source/blender/nodes/shader/nodes/node_shader_output_material.cc index 7d46e8e28fc..5fc95b92e3f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_material.cc +++ b/source/blender/nodes/shader/nodes/node_shader_output_material.cc @@ -28,7 +28,7 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_input(N_("Surface")); b.add_input(N_("Volume")); b.add_input(N_("Displacement")).hide_value(); -}; +} static int node_shader_gpu_output_material(GPUMaterial *mat, bNode *node, diff --git a/source/blender/nodes/shader/nodes/node_shader_output_world.cc b/source/blender/nodes/shader/nodes/node_shader_output_world.cc index 9ea325bbf78..501dc088cbe 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_world.cc +++ b/source/blender/nodes/shader/nodes/node_shader_output_world.cc @@ -25,7 +25,7 @@ static void node_declare(NodeDeclarationBuilder &b) { b.add_input(N_("Surface")); b.add_input(N_("Volume")); -}; +} static int node_shader_gpu_output_world(GPUMaterial *mat, bNode *node, diff --git a/source/blender/nodes/shader/nodes/node_shader_particle_info.cc b/source/blender/nodes/shader/nodes/node_shader_particle_info.cc index 163a5d6ebfe..d68d0fe0d72 100644 --- a/source/blender/nodes/shader/nodes/node_shader_particle_info.cc +++ b/source/blender/nodes/shader/nodes/node_shader_particle_info.cc @@ -36,7 +36,7 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output(N_("Size")); b.add_output(N_("Velocity")); b.add_output(N_("Angular Velocity")); -}; +} static int gpu_shader_particle_info(GPUMaterial *mat, bNode *node, diff --git a/source/blender/nodes/shader/nodes/node_shader_rgb_to_bw.cc b/source/blender/nodes/shader/nodes/node_shader_rgb_to_bw.cc index d93c2326490..13ba056d9ee 100644 --- a/source/blender/nodes/shader/nodes/node_shader_rgb_to_bw.cc +++ b/source/blender/nodes/shader/nodes/node_shader_rgb_to_bw.cc @@ -31,7 +31,7 @@ static void sh_node_rgbtobw_declare(NodeDeclarationBuilder &b) { b.add_input(N_("Color")).default_value({0.5f, 0.5f, 0.5f, 1.0f}); b.add_output(N_("Val")); -}; +} static int gpu_shader_rgbtobw(GPUMaterial *mat, bNode *node, diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcomb_rgb.cc b/source/blender/nodes/shader/nodes/node_shader_sepcomb_rgb.cc index 5ca2d4e2f68..d4be0bd14dc 100644 --- a/source/blender/nodes/shader/nodes/node_shader_sepcomb_rgb.cc +++ b/source/blender/nodes/shader/nodes/node_shader_sepcomb_rgb.cc @@ -32,7 +32,7 @@ static void sh_node_seprgb_declare(NodeDeclarationBuilder &b) b.add_output(N_("R")); b.add_output(N_("G")); b.add_output(N_("B")); -}; +} static int gpu_shader_seprgb(GPUMaterial *mat, bNode *node, @@ -111,7 +111,7 @@ static void sh_node_combrgb_declare(NodeDeclarationBuilder &b) b.add_input(N_("G")).min(0.0f).max(1.0f); b.add_input(N_("B")).min(0.0f).max(1.0f); b.add_output(N_("Image")); -}; +} static int gpu_shader_combrgb(GPUMaterial *mat, bNode *node, diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcomb_xyz.cc b/source/blender/nodes/shader/nodes/node_shader_sepcomb_xyz.cc index 57eef716e88..f8064eb192a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_sepcomb_xyz.cc +++ b/source/blender/nodes/shader/nodes/node_shader_sepcomb_xyz.cc @@ -32,7 +32,7 @@ static void sh_node_sepxyz_declare(NodeDeclarationBuilder &b) b.add_output(N_("X")); b.add_output(N_("Y")); b.add_output(N_("Z")); -}; +} static int gpu_shader_sepxyz(GPUMaterial *mat, bNode *node, @@ -111,7 +111,7 @@ static void sh_node_combxyz_declare(NodeDeclarationBuilder &b) b.add_input(N_("Y")).min(-10000.0f).max(10000.0f); b.add_input(N_("Z")).min(-10000.0f).max(10000.0f); b.add_output(N_("Vector")); -}; +} static int gpu_shader_combxyz(GPUMaterial *mat, bNode *node, diff --git a/source/blender/nodes/shader/nodes/node_shader_shader_to_rgb.cc b/source/blender/nodes/shader/nodes/node_shader_shader_to_rgb.cc index 2e0ba3f1a36..153b1abfbca 100644 --- a/source/blender/nodes/shader/nodes/node_shader_shader_to_rgb.cc +++ b/source/blender/nodes/shader/nodes/node_shader_shader_to_rgb.cc @@ -26,7 +26,7 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_input(N_("Shader")); b.add_output(N_("Color")); b.add_output(N_("Alpha")); -}; +} static int node_shader_gpu_shadertorgb(GPUMaterial *mat, bNode *node, diff --git a/source/blender/nodes/shader/nodes/node_shader_tangent.cc b/source/blender/nodes/shader/nodes/node_shader_tangent.cc index fb5637648f7..c4e5660b9f8 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tangent.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tangent.cc @@ -29,7 +29,7 @@ namespace blender::nodes::node_shader_tangent_cc { static void node_declare(NodeDeclarationBuilder &b) { b.add_output(N_("Tangent")); -}; +} static void node_shader_buts_tangent(uiLayout *layout, bContext *C, PointerRNA *ptr) { diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc b/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc index b8cb00a6487..61b1613c11a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc @@ -58,7 +58,7 @@ static void sh_node_tex_brick_declare(NodeDeclarationBuilder &b) .no_muted_links(); b.add_output(N_("Color")); b.add_output(N_("Fac")); -}; +} static void node_shader_buts_tex_brick(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_checker.cc b/source/blender/nodes/shader/nodes/node_shader_tex_checker.cc index f22af9f4963..6022f13821a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_checker.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_checker.cc @@ -34,7 +34,7 @@ static void sh_node_tex_checker_declare(NodeDeclarationBuilder &b) .no_muted_links(); b.add_output(N_("Color")); b.add_output(N_("Fac")); -}; +} static void node_shader_init_tex_checker(bNodeTree *UNUSED(ntree), bNode *node) { diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc index 352cde0b947..85e0f262ca7 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc @@ -30,7 +30,7 @@ static void sh_node_tex_gradient_declare(NodeDeclarationBuilder &b) b.add_input(N_("Vector")).hide_value().implicit_field(); b.add_output(N_("Color")).no_muted_links(); b.add_output(N_("Fac")).no_muted_links(); -}; +} static void node_shader_buts_tex_gradient(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.cc b/source/blender/nodes/shader/nodes/node_shader_tex_image.cc index 745121691ac..d5479f46a35 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.cc @@ -27,7 +27,7 @@ static void sh_node_tex_image_declare(NodeDeclarationBuilder &b) b.add_input(N_("Vector")).implicit_field(); b.add_output(N_("Color")).no_muted_links(); b.add_output(N_("Alpha")).no_muted_links(); -}; +} static void node_shader_init_tex_image(bNodeTree *UNUSED(ntree), bNode *node) { diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_magic.cc b/source/blender/nodes/shader/nodes/node_shader_tex_magic.cc index 22a0532b57b..e40914783b6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_magic.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_magic.cc @@ -32,7 +32,7 @@ static void sh_node_tex_magic_declare(NodeDeclarationBuilder &b) b.add_input(N_("Distortion")).min(-1000.0f).max(1000.0f).default_value(1.0f); b.add_output(N_("Color")).no_muted_links(); b.add_output(N_("Fac")).no_muted_links(); -}; +} static void node_shader_buts_tex_magic(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc index 52ab70848de..45c2a83c178 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc @@ -43,7 +43,7 @@ static void sh_node_tex_musgrave_declare(NodeDeclarationBuilder &b) b.add_input(N_("Offset")).min(-1000.0f).max(1000.0f); b.add_input(N_("Gain")).min(0.0f).max(1000.0f).default_value(1.0f); b.add_output(N_("Fac")).no_muted_links(); -}; +} static void node_shader_buts_tex_musgrave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { 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 9e378ff0110..0e549859a39 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc @@ -46,7 +46,7 @@ static void sh_node_tex_noise_declare(NodeDeclarationBuilder &b) b.add_input(N_("Distortion")).min(-1000.0f).max(1000.0f).default_value(0.0f); b.add_output(N_("Fac")).no_muted_links(); b.add_output(N_("Color")).no_muted_links(); -}; +} static void node_shader_buts_tex_noise(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc index 22f02fecffd..2b5c1ddfe21 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc @@ -63,7 +63,7 @@ static void sh_node_tex_voronoi_declare(NodeDeclarationBuilder &b) b.add_output(N_("Radius")).no_muted_links().make_available([](bNode &node) { node_storage(node).feature = SHD_VORONOI_N_SPHERE_RADIUS; }); -}; +} static void node_shader_buts_tex_voronoi(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_wave.cc b/source/blender/nodes/shader/nodes/node_shader_tex_wave.cc index 1216614a8ef..fc6c66061ff 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_wave.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_wave.cc @@ -42,7 +42,7 @@ static void sh_node_tex_wave_declare(NodeDeclarationBuilder &b) b.add_input(N_("Phase Offset")).min(-1000.0f).max(1000.0f).default_value(0.0f); b.add_output(N_("Color")).no_muted_links(); b.add_output(N_("Fac")).no_muted_links(); -}; +} static void node_shader_buts_tex_wave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc b/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc index 49bf622e2a5..3a5bc98896c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc @@ -36,7 +36,7 @@ static void sh_node_tex_white_noise_declare(NodeDeclarationBuilder &b) }); b.add_output(N_("Value")); b.add_output(N_("Color")); -}; +} static void node_shader_buts_white_noise(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { diff --git a/source/blender/nodes/shader/nodes/node_shader_value.cc b/source/blender/nodes/shader/nodes/node_shader_value.cc index 21f2e072990..265f03e6e88 100644 --- a/source/blender/nodes/shader/nodes/node_shader_value.cc +++ b/source/blender/nodes/shader/nodes/node_shader_value.cc @@ -28,7 +28,7 @@ namespace blender::nodes::node_shader_value_cc { static void sh_node_value_declare(NodeDeclarationBuilder &b) { b.add_output(N_("Value")); -}; +} static int gpu_shader_value(GPUMaterial *mat, bNode *node, diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc index 1fa4d712d27..591734c7dd6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc @@ -42,7 +42,7 @@ static void sh_node_vector_math_declare(NodeDeclarationBuilder &b) b.add_input(N_("Scale")).default_value(1.0f).min(-10000.0f).max(10000.0f); b.add_output(N_("Vector")); b.add_output(N_("Value")); -}; +} static void node_shader_buts_vect_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc b/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc index a59d3039e4e..d8dcd028c56 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc @@ -37,7 +37,7 @@ static void sh_node_vector_rotate_declare(NodeDeclarationBuilder &b) b.add_input(N_("Angle")).subtype(PROP_ANGLE); b.add_input(N_("Rotation")).subtype(PROP_EULER); b.add_output(N_("Vector")); -}; +} static void node_shader_buts_vector_rotate(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { -- cgit v1.2.3 From faeab8367c68356c1defa7db78cb841c087faa45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 6 Jan 2022 18:01:46 +0100 Subject: BLI_floatX: Add most missing constructors and operator This should have no side effect. This reverse the dependency, with `float2` being needed for `float3` and so on. This is needed for extensive usage of these types in the draw engines. Differential Revision: https://developer.blender.org/D13756 --- source/blender/nodes/shader/nodes/node_shader_tex_noise.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/nodes/shader') 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 0e549859a39..1c703313edf 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc @@ -176,14 +176,14 @@ class NoiseFunction : public fn::MultiFunction { const VArray &vector = params.readonly_single_input(0, "Vector"); if (compute_factor) { for (int64_t i : mask) { - const float2 position = vector[i] * scale[i]; + const float2 position = float2(vector[i] * scale[i]); r_factor[i] = noise::perlin_fractal_distorted( position, detail[i], roughness[i], distortion[i]); } } if (compute_color) { for (int64_t i : mask) { - const float2 position = vector[i] * scale[i]; + const float2 position = float2(vector[i] * scale[i]); const float3 c = noise::perlin_float3_fractal_distorted( position, detail[i], roughness[i], distortion[i]); r_color[i] = ColorGeometry4f(c[0], c[1], c[2], 1.0f); -- cgit v1.2.3