diff options
author | Aaron Carlisle <carlisle.b3d@gmail.com> | 2022-01-09 08:59:34 +0300 |
---|---|---|
committer | Aaron Carlisle <carlisle.b3d@gmail.com> | 2022-01-09 08:59:34 +0300 |
commit | e17ac8dc58c7108cfb3a784a595912c063e09cf4 (patch) | |
tree | 3a0a30fce007550c2743e423dd5f5017a0ca7753 /source/blender/nodes | |
parent | ed1ced24848824a4acbaaf7aa7ccb34441f6a8f4 (diff) |
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.
Diffstat (limited to 'source/blender/nodes')
37 files changed, 576 insertions, 2 deletions
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<decl::Float>(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<decl::Float>(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>("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<decl::Vector>(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<decl::Shader>(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<decl::Shader>(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<decl::Shader>(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<decl::Shader>(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<decl::Shader>(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<decl::Vector>(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<decl::Float>(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<decl::Float>(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<NodeShaderTexIES>("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<decl::Vector>(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<decl::Vector>(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<decl::Vector>(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>("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<decl::Float>(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>("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<decl::Shader>(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<decl::Vector>(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>("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<decl::Float>(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<NodeTexBrick>(__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<decl::Vector>(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<decl::Float>(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<NodeTexGradient>(__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<decl::Float>(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<NodeTexMagic>(__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<decl::Float>(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<NodeTexMusgrave>(__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<decl::Color>(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<NodeTexNoise>(__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<decl::Float>(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<NodeShaderTexPointDensity>("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<decl::Color>(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>("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<NodeTexVoronoi>(__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<decl::Float>(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<NodeTexWave>(__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<decl::Color>(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<decl::Vector>(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<decl::Vector>(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>("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<decl::Float>(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<decl::Vector>(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<decl::Vector>(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>("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<decl::Float>(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>("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<decl::Float>(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); |