diff options
author | Aaron Carlisle <carlisle.b3d@gmail.com> | 2021-12-07 02:51:19 +0300 |
---|---|---|
committer | Aaron Carlisle <carlisle.b3d@gmail.com> | 2021-12-07 02:52:08 +0300 |
commit | 97e3a2d935ba9b21b127eda7ca104d4bcf4e48bd (patch) | |
tree | 586cc0aad98acad4e1452ff4917a7ef56ce72fcb | |
parent | b1696702cdb74c2b6d7c8c3f9d204f108607a8ab (diff) |
Shader Nodes: Migrate shader category to new node socket declaration API
No functional changes, tests passed and I double checked the nodes by hand.
19 files changed, 272 insertions, 315 deletions
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 5a614e7b155..9fac8d70e9d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc @@ -23,20 +23,20 @@ namespace blender::nodes::node_shader_anisotropic_cc { -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<decl::Color>(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input<decl::Float>(N_("Roughness")) + .default_value(0.5f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("Anisotropy")).default_value(0.5f).min(-1.0f).max(1.0f); + b.add_input<decl::Float>(N_("Rotation")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Vector>(N_("Normal")).min(-1.0f).max(1.0f).hide_value(); + b.add_input<decl::Vector>(N_("Tangent")).min(-1.0f).max(1.0f).hide_value(); + b.add_output<decl::Shader>(N_("BSDF")); +} static void node_shader_init_anisotropic(bNodeTree *UNUSED(ntree), bNode *node) { @@ -76,8 +76,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, 0); - 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_storage(&ntype, "", nullptr, nullptr); 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 8b30436db09..c3ec80a4cf9 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.cc @@ -23,17 +23,13 @@ namespace blender::nodes::node_shader_bsdf_diffuse_cc { -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<decl::Color>(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input<decl::Float>(N_("Roughness")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Vector>(N_("Normal")).min(-1.0f).max(1.0f).hide_value(); + b.add_output<decl::Shader>(N_("BSDF")); +} static int node_shader_gpu_bsdf_diffuse(GPUMaterial *mat, bNode *node, @@ -60,8 +56,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, 0); - 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_init(&ntype, nullptr); node_type_storage(&ntype, "", nullptr, nullptr); 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 78ad2d7b121..840d7e68dbc 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.cc @@ -23,18 +23,14 @@ namespace blender::nodes::node_shader_bsdf_glass_cc { -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<decl::Color>(N_("Color")).default_value({1.0f, 1.0f, 1.0f, 1.0f}); + b.add_input<decl::Float>(N_("Roughness")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("IOR")).default_value(1.45f).min(0.0f).max(1000.0f); + b.add_input<decl::Vector>(N_("Normal")).min(-1.0f).max(1.0f).hide_value(); + b.add_output<decl::Shader>(N_("BSDF")); +} static void node_shader_init_glass(bNodeTree *UNUSED(ntree), bNode *node) { @@ -78,8 +74,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, 0); - 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_storage(&ntype, "", nullptr, nullptr); 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 cd12eac79e0..0090096fd42 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.cc @@ -23,17 +23,17 @@ namespace blender::nodes::node_shader_bsdf_glossy_cc { -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<decl::Color>(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input<decl::Float>(N_("Roughness")) + .default_value(0.5) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input<decl::Vector>(N_("Normal")).min(-1.0f).max(1.0f).hide_value(); + b.add_output<decl::Shader>(N_("BSDF")); +} static void node_shader_init_glossy(bNodeTree *UNUSED(ntree), bNode *node) { @@ -77,8 +77,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, 0); - 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_storage(&ntype, "", nullptr, nullptr); 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 dfd8c219f87..0bb0e886a7c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc @@ -23,19 +23,23 @@ namespace blender::nodes::node_shader_bsdf_hair_cc { -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<decl::Color>(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input<decl::Float>(N_("Offset")).min(-M_PI_2).max(M_PI_2).subtype(PROP_ANGLE); + b.add_input<decl::Float>(N_("RoughnessU")) + .default_value(0.1f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("RoughnessV")) + .default_value(1.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input<decl::Vector>(N_("Tangent")).min(-1.0f).max(1.0f).hide_value(); + b.add_output<decl::Shader>(N_("BSDF")); +} static int node_shader_gpu_bsdf_hair(GPUMaterial *mat, bNode *node, @@ -56,8 +60,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, 0); - 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_init(&ntype, nullptr); node_type_storage(&ntype, "", nullptr, nullptr); 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 4916728240c..55ac8bc4ff9 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 @@ -24,35 +24,47 @@ namespace blender::nodes::node_shader_bsdf_hair_principled_cc { /* 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 void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input<decl::Color>(N_("Color")).default_value({0.017513f, 0.005763f, 0.002059f, 1.0f}); + b.add_input<decl::Float>(N_("Melanin")) + .default_value(0.8f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("Melanin Redness")) + .default_value(1.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input<decl::Color>(N_("Tint")).default_value({1.0f, 1.0f, 1.0f, 1.0f}); + b.add_input<decl::Vector>(N_("Absorption Coefficient")) + .default_value({0.245531f, 0.52f, 1.365f}) + .min(0.0f) + .max(1000.0f); -static bNodeSocketTemplate sh_node_bsdf_hair_principled_out[] = { - {SOCK_SHADER, N_("BSDF")}, - {-1, ""}, -}; + b.add_input<decl::Float>(N_("Roughness")) + .default_value(0.3f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("Radial Roughness")) + .default_value(0.3f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("Coat")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("IOR")).default_value(1.55f).min(0.0f).max(1000.0f); + b.add_input<decl::Float>(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<decl::Float>(N_("Random Color")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("Random Roughness")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("Random")).min(0.0f).max(1.0f).hide_value(); + b.add_output<decl::Shader>(N_("BSDF")); +} /* Initialize the custom Parametrization property to Color. */ static void node_shader_init_hair_principled(bNodeTree *UNUSED(ntree), bNode *node) @@ -103,8 +115,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, 0); - 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_storage(&ntype, "", nullptr, nullptr); 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 00036bfb662..ff01a9d6a91 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc @@ -23,57 +23,60 @@ namespace blender::nodes::node_shader_bsdf_principled_cc { -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<decl::Color>(N_("Base Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input<decl::Float>(N_("Subsurface")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Vector>(N_("Subsurface Radius")) + .default_value({1.0f, 0.2f, 0.1f}) + .min(0.0f) + .max(100.0f) + .compact(); + b.add_input<decl::Color>(N_("Subsurface Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input<decl::Float>(N_("Subsurface IOR")) + .default_value(1.4f) + .min(1.01f) + .max(3.8f) + .subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("Subsurface Anisotropy")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("Metallic")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("Specular")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("Specular Tint")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("Roughness")) + .default_value(0.5f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("Anisotropic")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("Anisotropic Rotation")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("Sheen")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("Sheen Tint")) + .default_value(0.5f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("Clearcoat")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("Clearcoat Roughness")) + .default_value(0.03f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("IOR")).default_value(1.45f).min(0.0f).max(1000.0f).subtype( + PROP_FACTOR); + b.add_input<decl::Float>(N_("Transmission")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("Transmission Roughness")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Color>(N_("Emission")).default_value({0.0f, 0.0f, 0.0f, 1.0f}); + b.add_input<decl::Float>(N_("Emission Strength")).default_value(1.0f).min(0.0f).max(1000000.0f); + b.add_input<decl::Float>(N_("Alpha")) + .default_value(1.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input<decl::Vector>(N_("Normal")).min(-1.0f).max(1.0f).hide_value(); + b.add_input<decl::Vector>(N_("Clearcoat Normal")).min(-1.0f).max(1.0f).hide_value(); + b.add_input<decl::Vector>(N_("Tangent")).min(-1.0f).max(1.0f).hide_value(); + b.add_output<decl::Shader>(N_("BSDF")); +} static void node_shader_init_principled(bNodeTree *UNUSED(ntree), bNode *node) { @@ -195,8 +198,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, 0); - 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_storage(&ntype, "", nullptr, nullptr); 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 5918364e1cf..432e69331e0 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.cc @@ -23,18 +23,14 @@ namespace blender::nodes::node_shader_bsdf_refraction_cc { -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<decl::Color>(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input<decl::Float>(N_("Roughness")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("IOR")).default_value(1.45f).min(0.0f).max(1000.0f); + b.add_input<decl::Vector>(N_("Normal")).min(-1.0f).max(1.0f).hide_value(); + b.add_output<decl::Shader>(N_("BSDF")); +} static void node_shader_init_refraction(bNodeTree *UNUSED(ntree), bNode *node) { @@ -70,8 +66,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, 0); - 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_storage(&ntype, "", nullptr, nullptr); 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 73a3d552b9a..8d8e198b7fc 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc @@ -23,18 +23,18 @@ namespace blender::nodes::node_shader_bsdf_toon_cc { -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<decl::Color>(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input<decl::Float>(N_("Size")) + .default_value(0.5f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("Smooth")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Vector>(N_("Normal")).min(-1.0f).max(1.0f).hide_value(); + b.add_output<decl::Shader>(N_("BSDF")); +} static int node_shader_gpu_bsdf_toon(GPUMaterial *mat, bNode *node, @@ -61,8 +61,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, 0); - 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_init(&ntype, nullptr); node_type_storage(&ntype, "", nullptr, nullptr); 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 662a8dd57fe..5633f422fb8 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.cc @@ -23,16 +23,12 @@ namespace blender::nodes::node_shader_bsdf_translucent_cc { -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<decl::Color>(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input<decl::Vector>(N_("Normal")).min(-1.0f).max(1.0f).hide_value(); + b.add_output<decl::Shader>(N_("BSDF")); +} static int node_shader_gpu_bsdf_translucent(GPUMaterial *mat, bNode *node, @@ -59,8 +55,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, 0); - 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_init(&ntype, nullptr); node_type_storage(&ntype, "", nullptr, nullptr); node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_translucent); 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 f2fc7344bbb..1c8e77781fe 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.cc @@ -23,15 +23,11 @@ namespace blender::nodes::node_shader_bsdf_transparent_cc { -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<decl::Color>(N_("Color")).default_value({1.0f, 1.0f, 1.0f, 1.0f}); + b.add_output<decl::Shader>(N_("BSDF")); +} static int node_shader_gpu_bsdf_transparent(GPUMaterial *mat, bNode *node, @@ -52,8 +48,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, 0); - 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_init(&ntype, nullptr); node_type_storage(&ntype, "", nullptr, nullptr); node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_transparent); 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 667eef663c2..6762b52c959 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.cc @@ -23,17 +23,17 @@ namespace blender::nodes::node_shader_bsdf_velvet_cc { -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<decl::Color>(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input<decl::Float>(N_("Sigma")) + .default_value(1.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input<decl::Vector>(N_("Normal")).min(-1.0f).max(1.0f).hide_value(); + b.add_output<decl::Shader>(N_("BSDF")); +} static int node_shader_gpu_bsdf_velvet(GPUMaterial *mat, bNode *node, @@ -60,8 +60,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, 0); - 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_init(&ntype, nullptr); node_type_storage(&ntype, "", nullptr, nullptr); node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_velvet); diff --git a/source/blender/nodes/shader/nodes/node_shader_emission.cc b/source/blender/nodes/shader/nodes/node_shader_emission.cc index 8026879e656..afd250b1a9a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_emission.cc +++ b/source/blender/nodes/shader/nodes/node_shader_emission.cc @@ -23,16 +23,12 @@ namespace blender::nodes::node_shader_emission_cc { -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<decl::Color>(N_("Color")).default_value({1.0f, 1.0f, 1.0f, 1.0f}); + b.add_input<decl::Float>(N_("Strength")).default_value(1.0f).min(0.0f).max(1000000.0f); + b.add_output<decl::Shader>(N_("Emission")); +} static int node_shader_gpu_emission(GPUMaterial *mat, bNode *node, @@ -53,7 +49,7 @@ void register_node_type_sh_emission() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_EMISSION, "Emission", NODE_CLASS_SHADER, 0); - 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_init(&ntype, nullptr); node_type_storage(&ntype, "", nullptr, nullptr); node_type_gpu(&ntype, file_ns::node_shader_gpu_emission); diff --git a/source/blender/nodes/shader/nodes/node_shader_holdout.cc b/source/blender/nodes/shader/nodes/node_shader_holdout.cc index a0e8124d9dd..02bfda39d78 100644 --- a/source/blender/nodes/shader/nodes/node_shader_holdout.cc +++ b/source/blender/nodes/shader/nodes/node_shader_holdout.cc @@ -23,14 +23,10 @@ namespace blender::nodes::node_shader_holdout_cc { -static bNodeSocketTemplate sh_node_holdout_in[] = { - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_holdout_out[] = { - {SOCK_SHADER, N_("Holdout")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_output<decl::Shader>(N_("Holdout")); +} static int gpu_shader_rgb(GPUMaterial *mat, bNode *node, @@ -51,7 +47,7 @@ void register_node_type_sh_holdout() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_HOLDOUT, "Holdout", NODE_CLASS_SHADER, 0); - node_type_socket_templates(&ntype, file_ns::sh_node_holdout_in, file_ns::sh_node_holdout_out); + ntype.declare = file_ns::node_declare; node_type_init(&ntype, nullptr); node_type_storage(&ntype, "", nullptr, nullptr); node_type_gpu(&ntype, file_ns::gpu_shader_rgb); 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 d9cdd43490a..7254a0b2976 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mix_shader.cc +++ b/source/blender/nodes/shader/nodes/node_shader_mix_shader.cc @@ -23,17 +23,13 @@ namespace blender::nodes::node_shader_mix_shader_cc { -static bNodeSocketTemplate sh_node_mix_shader_in[] = { - {SOCK_FLOAT, N_("Fac"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {SOCK_SHADER, N_("Shader")}, - {SOCK_SHADER, N_("Shader")}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_mix_shader_out[] = { - {SOCK_SHADER, N_("Shader")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input<decl::Float>(N_("Fac")).default_value(0.5f).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Shader>(N_("Shader")); + b.add_input<decl::Shader>(N_("Shader"), "Shader_001"); + b.add_output<decl::Shader>(N_("Shader")); +} static int node_shader_gpu_mix_shader(GPUMaterial *mat, bNode *node, @@ -54,8 +50,7 @@ void register_node_type_sh_mix_shader() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_MIX_SHADER, "Mix Shader", NODE_CLASS_SHADER, 0); - node_type_socket_templates( - &ntype, file_ns::sh_node_mix_shader_in, file_ns::sh_node_mix_shader_out); + ntype.declare = file_ns::node_declare; node_type_init(&ntype, nullptr); node_type_storage(&ntype, "", nullptr, nullptr); node_type_gpu(&ntype, file_ns::node_shader_gpu_mix_shader); 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 017ef71754b..943ef45cc44 100644 --- a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc +++ b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc @@ -23,20 +23,20 @@ namespace blender::nodes::node_shader_subsurface_scattering_cc { -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<decl::Color>(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input<decl::Float>(N_("Scale")).default_value(1.0f).min(0.0f).max(1000.0f); + b.add_input<decl::Vector>(N_("Radius")) + .default_value({1.0f, 0.2f, 0.1f}) + .min(0.0f) + .max(100.0f) + .compact(); + b.add_input<decl::Float>(N_("IOR")).default_value(1.4f).min(0.0f).max(3.8f).subtype(PROP_FACTOR); + b.add_input<decl::Float>(N_("Anisotropy")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Vector>(N_("Normal")).min(-1.0f).max(1.0f).hide_value(); + b.add_output<decl::Shader>(N_("BSSRDF")); +} static void node_shader_init_subsurface_scattering(bNodeTree *UNUSED(ntree), bNode *node) { @@ -91,9 +91,7 @@ void register_node_type_sh_subsurface_scattering() sh_node_type_base( &ntype, SH_NODE_SUBSURFACE_SCATTERING, "Subsurface Scattering", NODE_CLASS_SHADER, 0); - 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_storage(&ntype, "", nullptr, nullptr); 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 f68121ad922..550530b4bc0 100644 --- a/source/blender/nodes/shader/nodes/node_shader_volume_absorption.cc +++ b/source/blender/nodes/shader/nodes/node_shader_volume_absorption.cc @@ -23,16 +23,12 @@ namespace blender::nodes::node_shader_volume_absorption_cc { -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<decl::Color>(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input<decl::Float>(N_("Density")).default_value(1.0f).min(0.0f).max(1000.0f); + b.add_output<decl::Shader>(N_("Volume")); +} static int node_shader_gpu_volume_absorption(GPUMaterial *mat, bNode *node, @@ -53,8 +49,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, 0); - 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_init(&ntype, nullptr); node_type_storage(&ntype, "", nullptr, nullptr); node_type_gpu(&ntype, file_ns::node_shader_gpu_volume_absorption); 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 8bf21a3a711..bdba452ccb2 100644 --- a/source/blender/nodes/shader/nodes/node_shader_volume_principled.cc +++ b/source/blender/nodes/shader/nodes/node_shader_volume_principled.cc @@ -23,26 +23,22 @@ namespace blender::nodes::node_shader_volume_principled_cc { -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<decl::Color>(N_("Color")).default_value({0.5f, 0.5f, 0.5f, 1.0f}); + b.add_input<decl::String>(N_("Color Attribute")); + b.add_input<decl::Float>(N_("Density")).default_value(1.0f).min(0.0f).max(1000.0f); + b.add_input<decl::String>(N_("Density Attribute")); + b.add_input<decl::Float>(N_("Anisotropy")).min(-1.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Color>(N_("Absorption Color")); + b.add_input<decl::Float>(N_("Emission Strength")).min(0.0f).max(1000.0f); + b.add_input<decl::Color>(N_("Emission Color")).default_value({1.0f, 1.0f, 1.0f, 1.0f}); + b.add_input<decl::Float>(N_("Blackbody Intensity")).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input<decl::Color>(N_("Blackbody Tint")).default_value({1.0f, 1.0f, 1.0f, 1.0f}); + b.add_input<decl::Float>(N_("Temperature")).default_value(1000.0f).min(0.0f).max(6500.0f); + b.add_input<decl::String>(N_("Temperature Attribute")); + b.add_output<decl::Shader>(N_("Volume")); +} static void node_shader_init_volume_principled(bNodeTree *UNUSED(ntree), bNode *node) { @@ -138,8 +134,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, 0); - 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_storage(&ntype, "", nullptr, nullptr); diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_scatter.cc b/source/blender/nodes/shader/nodes/node_shader_volume_scatter.cc index d9c84650abb..736707ab55d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_volume_scatter.cc +++ b/source/blender/nodes/shader/nodes/node_shader_volume_scatter.cc @@ -23,17 +23,13 @@ namespace blender::nodes::node_shader_volume_scatter_cc { -static bNodeSocketTemplate sh_node_volume_scatter_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}, - {SOCK_FLOAT, N_("Anisotropy"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_FACTOR}, - {-1, ""}, -}; - -static bNodeSocketTemplate sh_node_volume_scatter_out[] = { - {SOCK_SHADER, N_("Volume")}, - {-1, ""}, -}; +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_input<decl::Color>(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input<decl::Float>(N_("Density")).default_value(1.0f).min(0.0f).max(1000.0f); + b.add_input<decl::Float>(N_("Anisotropy")).min(-1.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_output<decl::Shader>(N_("Volume")); +} static int node_shader_gpu_volume_scatter(GPUMaterial *mat, bNode *node, @@ -54,8 +50,7 @@ void register_node_type_sh_volume_scatter() static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_VOLUME_SCATTER, "Volume Scatter", NODE_CLASS_SHADER, 0); - node_type_socket_templates( - &ntype, file_ns::sh_node_volume_scatter_in, file_ns::sh_node_volume_scatter_out); + ntype.declare = file_ns::node_declare; node_type_init(&ntype, nullptr); node_type_storage(&ntype, "", nullptr, nullptr); node_type_gpu(&ntype, file_ns::node_shader_gpu_volume_scatter); |