Blender V4.3
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
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*/,
29 GPUNodeStack *in,
30 GPUNodeStack *out)
31{
32 return GPU_stack_link(mat, node, "separate_rgb", in, out);
33}
34
36 public:
38 {
39 static const 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
69{
70 static SeparateRGBFunction fn;
71 builder.set_matching_fn(fn);
72}
73
74} // namespace blender::nodes::node_shader_sepcomb_rgb_cc
75
77{
79
80 static blender::bke::bNodeType ntype;
81
83 &ntype, SH_NODE_SEPRGB_LEGACY, "Separate RGB (Legacy)", NODE_CLASS_CONVERTER);
84 ntype.declare = file_ns::sh_node_seprgb_declare;
85 ntype.gpu_fn = file_ns::gpu_shader_seprgb;
86 ntype.build_multi_function = file_ns::sh_node_seprgb_build_multi_function;
87 ntype.gather_link_search_ops = nullptr;
88
90}
91
93
95{
96 b.is_function_node();
97 b.add_input<decl::Float>("R").min(0.0f).max(1.0f).translation_context(BLT_I18NCONTEXT_COLOR);
98 b.add_input<decl::Float>("G").min(0.0f).max(1.0f).translation_context(BLT_I18NCONTEXT_COLOR);
99 b.add_input<decl::Float>("B").min(0.0f).max(1.0f).translation_context(BLT_I18NCONTEXT_COLOR);
100 b.add_output<decl::Color>("Image");
101}
102
104 bNode *node,
105 bNodeExecData * /*execdata*/,
106 GPUNodeStack *in,
107 GPUNodeStack *out)
108{
109 return GPU_stack_link(mat, node, "combine_rgb", in, out);
110}
111
113{
114 static auto fn = mf::build::SI3_SO<float, float, float, ColorGeometry4f>(
115 "Combine RGB", [](float r, float g, float b) { return ColorGeometry4f(r, g, b, 1.0f); });
116 builder.set_matching_fn(fn);
117}
118
119} // namespace blender::nodes::node_shader_sepcomb_rgb_cc
120
122{
124
125 static blender::bke::bNodeType ntype;
126
128 &ntype, SH_NODE_COMBRGB_LEGACY, "Combine RGB (Legacy)", NODE_CLASS_CONVERTER);
129 ntype.declare = file_ns::sh_node_combrgb_declare;
130 ntype.gpu_fn = file_ns::gpu_shader_combrgb;
131 ntype.build_multi_function = file_ns::sh_node_combrgb_build_multi_function;
132 ntype.gather_link_search_ops = nullptr;
133
135}
#define SH_NODE_COMBRGB_LEGACY
Definition BKE_node.hh:910
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:410
#define SH_NODE_SEPRGB_LEGACY
Definition BKE_node.hh:909
#define BLT_I18NCONTEXT_COLOR
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
ChannelStorageType r
Definition BLI_color.hh:88
void set_signature(const Signature *signature)
void set_matching_fn(const mf::MultiFunction *fn)
void call(const IndexMask &mask, mf::Params params, mf::Context) const override
local_group_size(16, 16) .push_constant(Type b
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
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:337
void register_node_type_sh_seprgb()
void register_node_type_sh_combrgb()
void sh_fn_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
#define min(a, b)
Definition sort.c:32
__int64 int64_t
Definition stdint.h:89
Defines a node type.
Definition BKE_node.hh:218
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:318
NodeMultiFunctionBuildFunction build_multi_function
Definition BKE_node.hh:336
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
Definition BKE_node.hh:363
NodeDeclareFunction declare
Definition BKE_node.hh:347