diff options
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/CMakeLists.txt | 2 | ||||
-rw-r--r-- | source/blender/nodes/shader/node_shader_util.h | 1 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc (renamed from source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c) | 45 |
3 files changed, 47 insertions, 1 deletions
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index ff512e1ddf7..9106eacb31a 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -193,7 +193,7 @@ set(SRC shader/nodes/node_shader_rgb.c shader/nodes/node_shader_script.c shader/nodes/node_shader_sepcombHSV.c - shader/nodes/node_shader_sepcombRGB.c + shader/nodes/node_shader_sepcombRGB.cc shader/nodes/node_shader_sepcombXYZ.cc shader/nodes/node_shader_shaderToRgb.c shader/nodes/node_shader_squeeze.c diff --git a/source/blender/nodes/shader/node_shader_util.h b/source/blender/nodes/shader/node_shader_util.h index 9ea3974679a..2aed485c8bc 100644 --- a/source/blender/nodes/shader/node_shader_util.h +++ b/source/blender/nodes/shader/node_shader_util.h @@ -75,6 +75,7 @@ # include "BKE_node_tree_multi_function.hh" +# include "BLI_color.hh" # include "BLI_float3.hh" extern "C" { diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc index d0dc45dcedd..8cab115c0b5 100644 --- a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c +++ b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc @@ -59,6 +59,42 @@ static int gpu_shader_seprgb(GPUMaterial *mat, return GPU_stack_link(mat, node, "separate_rgb", in, out); } +class SeparateRGBFunction : public blender::fn::MultiFunction { + public: + SeparateRGBFunction() + { + blender::fn::MFSignatureBuilder signature = this->get_builder("Separate RGB"); + signature.single_input<blender::Color4f>("Color"); + signature.single_output<float>("R"); + signature.single_output<float>("G"); + signature.single_output<float>("B"); + } + + void call(blender::IndexMask mask, + blender::fn::MFParams params, + blender::fn::MFContext UNUSED(context)) const override + { + blender::fn::VSpan<blender::Color4f> colors = params.readonly_single_input<blender::Color4f>( + 0, "Color"); + blender::MutableSpan<float> rs = params.uninitialized_single_output<float>(1, "R"); + blender::MutableSpan<float> gs = params.uninitialized_single_output<float>(2, "G"); + blender::MutableSpan<float> bs = params.uninitialized_single_output<float>(3, "B"); + + for (uint i : mask) { + blender::Color4f color = colors[i]; + rs[i] = color.r; + gs[i] = color.g; + bs[i] = color.b; + } + } +}; + +static void sh_node_seprgb_expand_in_mf_network(blender::bke::NodeMFNetworkBuilder &builder) +{ + static SeparateRGBFunction fn; + builder.set_matching_fn(fn); +} + void register_node_type_sh_seprgb(void) { static bNodeType ntype; @@ -67,6 +103,7 @@ void register_node_type_sh_seprgb(void) node_type_socket_templates(&ntype, sh_node_seprgb_in, sh_node_seprgb_out); node_type_exec(&ntype, NULL, NULL, node_shader_exec_seprgb); node_type_gpu(&ntype, gpu_shader_seprgb); + ntype.expand_in_mf_network = sh_node_seprgb_expand_in_mf_network; nodeRegisterType(&ntype); } @@ -109,6 +146,13 @@ static int gpu_shader_combrgb(GPUMaterial *mat, return GPU_stack_link(mat, node, "combine_rgb", in, out); } +static void sh_node_combrgb_expand_in_mf_network(blender::bke::NodeMFNetworkBuilder &builder) +{ + static blender::fn::CustomMF_SI_SI_SI_SO<float, float, float, blender::Color4f> fn{ + "Combine RGB", [](float r, float g, float b) { return blender::Color4f(r, g, b, 1.0f); }}; + builder.set_matching_fn(fn); +} + void register_node_type_sh_combrgb(void) { static bNodeType ntype; @@ -117,6 +161,7 @@ void register_node_type_sh_combrgb(void) node_type_socket_templates(&ntype, sh_node_combrgb_in, sh_node_combrgb_out); node_type_exec(&ntype, NULL, NULL, node_shader_exec_combrgb); node_type_gpu(&ntype, gpu_shader_combrgb); + ntype.expand_in_mf_network = sh_node_combrgb_expand_in_mf_network; nodeRegisterType(&ntype); } |