Blender V4.5
node_shader_sepcomb_rgb.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2006 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "node_shader_util.hh"
10
12
13#include "NOD_multi_function.hh"
14
16
18{
19 b.is_function_node();
20 b.add_input<decl::Color>("Image").default_value({0.8f, 0.8f, 0.8f, 1.0f});
21 b.add_output<decl::Float>("R").translation_context(BLT_I18NCONTEXT_COLOR);
22 b.add_output<decl::Float>("G").translation_context(BLT_I18NCONTEXT_COLOR);
23 b.add_output<decl::Float>("B").translation_context(BLT_I18NCONTEXT_COLOR);
24}
25
27 bNode *node,
28 bNodeExecData * /*execdata*/,
31{
32 return GPU_stack_link(mat, node, "separate_rgb", in, out);
33}
34
35class SeparateRGBFunction : public mf::MultiFunction {
36 public:
38 {
39 static const mf::Signature signature = []() {
40 mf::Signature signature;
41 mf::SignatureBuilder builder{"Separate RGB", signature};
42 builder.single_input<ColorGeometry4f>("Color");
43 builder.single_output<float>("R");
44 builder.single_output<float>("G");
45 builder.single_output<float>("B");
46 return signature;
47 }();
48 this->set_signature(&signature);
49 }
50
51 void call(const IndexMask &mask, mf::Params params, mf::Context /*context*/) const override
52 {
53 const VArray<ColorGeometry4f> &colors = params.readonly_single_input<ColorGeometry4f>(0,
54 "Color");
55 MutableSpan<float> rs = params.uninitialized_single_output<float>(1, "R");
56 MutableSpan<float> gs = params.uninitialized_single_output<float>(2, "G");
57 MutableSpan<float> bs = params.uninitialized_single_output<float>(3, "B");
58
59 mask.foreach_index([&](const int64_t i) {
60 ColorGeometry4f color = colors[i];
61 rs[i] = color.r;
62 gs[i] = color.g;
63 bs[i] = color.b;
64 });
65 }
66};
67
73
74} // namespace blender::nodes::node_shader_sepcomb_rgb_cc
75
77{
79
80 static blender::bke::bNodeType ntype;
81
82 common_node_type_base(&ntype, "ShaderNodeSeparateRGB", SH_NODE_SEPRGB_LEGACY);
83 ntype.ui_name = "Separate RGB (Legacy)";
84 ntype.ui_description = "Deprecated";
85 ntype.enum_name_legacy = "SEPRGB";
87 ntype.declare = file_ns::sh_node_seprgb_declare;
88 ntype.gpu_fn = file_ns::gpu_shader_seprgb;
89 ntype.build_multi_function = file_ns::sh_node_seprgb_build_multi_function;
90 ntype.gather_link_search_ops = nullptr;
91
93}
94
96
98{
99 b.is_function_node();
100 b.add_input<decl::Float>("R").min(0.0f).max(1.0f).translation_context(BLT_I18NCONTEXT_COLOR);
101 b.add_input<decl::Float>("G").min(0.0f).max(1.0f).translation_context(BLT_I18NCONTEXT_COLOR);
102 b.add_input<decl::Float>("B").min(0.0f).max(1.0f).translation_context(BLT_I18NCONTEXT_COLOR);
103 b.add_output<decl::Color>("Image");
104}
105
107 bNode *node,
108 bNodeExecData * /*execdata*/,
111{
112 return GPU_stack_link(mat, node, "combine_rgb", in, out);
113}
114
116{
117 static auto fn = mf::build::SI3_SO<float, float, float, ColorGeometry4f>(
118 "Combine RGB", [](float r, float g, float b) { return ColorGeometry4f(r, g, b, 1.0f); });
119 builder.set_matching_fn(fn);
120}
121
122} // namespace blender::nodes::node_shader_sepcomb_rgb_cc
123
125{
127
128 static blender::bke::bNodeType ntype;
129
130 common_node_type_base(&ntype, "ShaderNodeCombineRGB", SH_NODE_COMBRGB_LEGACY);
131 ntype.ui_name = "Combine RGB (Legacy)";
132 ntype.ui_description = "Deprecated";
133 ntype.enum_name_legacy = "COMBRGB";
135 ntype.declare = file_ns::sh_node_combrgb_declare;
136 ntype.gpu_fn = file_ns::gpu_shader_combrgb;
137 ntype.build_multi_function = file_ns::sh_node_combrgb_build_multi_function;
138 ntype.gather_link_search_ops = nullptr;
139
141}
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:439
#define SH_NODE_COMBRGB_LEGACY
#define SH_NODE_SEPRGB_LEGACY
#define BLT_I18NCONTEXT_COLOR
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
long long int int64_t
void set_signature(const Signature *signature)
void set_matching_fn(const mf::MultiFunction *fn)
std::optional< std::string > translation_context
void call(const IndexMask &mask, mf::Params params, mf::Context) const override
#define in
#define out
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
void node_register_type(bNodeType &ntype)
Definition node.cc:2748
static int gpu_shader_combrgb(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static int gpu_shader_seprgb(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void sh_node_combrgb_declare(NodeDeclarationBuilder &b)
static void sh_node_seprgb_build_multi_function(NodeMultiFunctionBuilder &builder)
static void sh_node_combrgb_build_multi_function(NodeMultiFunctionBuilder &builder)
static void sh_node_seprgb_declare(NodeDeclarationBuilder &b)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
Definition BLI_color.hh:342
void register_node_type_sh_seprgb()
void register_node_type_sh_combrgb()
void common_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
#define min(a, b)
Definition sort.cc:36
Defines a node type.
Definition BKE_node.hh:226
std::string ui_description
Definition BKE_node.hh:232
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:330
NodeMultiFunctionBuildFunction build_multi_function
Definition BKE_node.hh:344
const char * enum_name_legacy
Definition BKE_node.hh:235
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
Definition BKE_node.hh:371
NodeDeclareFunction declare
Definition BKE_node.hh:355
i
Definition text_draw.cc:230