Blender V5.3
node_shader_rgb.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2005 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "node_shader_util.hh"
10
11#include "UI_interface.hh"
13#include "UI_resources.hh"
14
15namespace blender {
16
18
20{
21 b.add_output<decl::Color>("Color"_ustr)
22 .default_value({0.5f, 0.5f, 0.5f, 1.0f})
23 .custom_draw([](CustomSocketDrawParams &params) {
25 ui::Layout &col = params.layout.column(false);
26 template_color_picker(
27 &col, &params.socket_ptr, "default_value", true, false, false, false);
28 col.prop(&params.socket_ptr, "default_value", ui::ITEM_R_SLIDER, "", ICON_NONE);
29 });
30}
31
33 bNode *node,
34 bNodeExecData * /*execdata*/,
35 GPUNodeStack * /*in*/,
37{
38 const bNodeSocket *socket = node->outputs.first();
39 float *value = static_cast<bNodeSocketValueRGBA *>(socket->default_value)->value;
40 return GPU_link(mat, "set_rgba", GPU_uniform(value), &out->link);
41}
42
44#ifdef WITH_MATERIALX
45{
46 NodeItem color = get_output_default("Color", NodeItem::Type::Color3);
47 return create_node("constant", NodeItem::Type::Color3, {{"value", color}});
48}
49#endif
51
52} // namespace nodes::node_shader_rgb_cc
53
55{
56 namespace file_ns = nodes::node_shader_rgb_cc;
57
58 static bke::bNodeType ntype;
59
60 sh_node_type_base(&ntype, "ShaderNodeRGB"_ustr, SH_NODE_RGB);
61 ntype.ui_name = "Color";
62 ntype.ui_description = "A color picker";
63 ntype.enum_name_legacy = "RGB";
65 ntype.declare = file_ns::node_declare;
66 ntype.gpu_fn = file_ns::gpu_shader_rgb;
67 ntype.materialx_fn = file_ns::node_shader_materialx;
68
70}
71
72} // namespace blender
#define NODE_CLASS_INPUT
Definition BKE_node.hh:478
#define SH_NODE_RGB
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static void node_declare(NodeDeclarationBuilder &b)
static int gpu_shader_rgb(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *, GPUNodeStack *out)
BMesh Iterators.
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
GPUNodeLink * GPU_uniform(const float *num)
bool GPU_link(GPUMaterial *mat, const char *name,...)
void register_node_type_sh_rgb()
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
Defines a node type.
Definition BKE_node.hh:265
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:375
std::string ui_description
Definition BKE_node.hh:271
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:373
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeDeclareFunction declare
Definition BKE_node.hh:393
void alignment_set(LayoutAlign alignment)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
Layout & column(bool align)