Blender V5.0
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
16
18{
19 b.add_output<decl::Color>("Color")
20 .default_value({0.5f, 0.5f, 0.5f, 1.0f})
21 .custom_draw([](CustomSocketDrawParams &params) {
22 params.layout.alignment_set(ui::LayoutAlign::Expand);
23 uiLayout &col = params.layout.column(false);
25 &col, &params.socket_ptr, "default_value", true, false, false, false);
26 col.prop(&params.socket_ptr, "default_value", UI_ITEM_R_SLIDER, "", ICON_NONE);
27 });
28}
29
31 bNode *node,
32 bNodeExecData * /*execdata*/,
33 GPUNodeStack * /*in*/,
35{
36 const bNodeSocket *socket = static_cast<bNodeSocket *>(node->outputs.first);
37 float *value = static_cast<bNodeSocketValueRGBA *>(socket->default_value)->value;
38 return GPU_link(mat, "set_rgba", GPU_uniform(value), &out->link);
39}
40
42#ifdef WITH_MATERIALX
43{
44 NodeItem color = get_output_default("Color", NodeItem::Type::Color3);
45 return create_node("constant", NodeItem::Type::Color3, {{"value", color}});
46}
47#endif
49
50} // namespace blender::nodes::node_shader_rgb_cc
51
53{
54 namespace file_ns = blender::nodes::node_shader_rgb_cc;
55
56 static blender::bke::bNodeType ntype;
57
58 sh_node_type_base(&ntype, "ShaderNodeRGB", SH_NODE_RGB);
59 ntype.ui_name = "Color";
60 ntype.ui_description = "A color picker";
61 ntype.enum_name_legacy = "RGB";
63 ntype.declare = file_ns::node_declare;
64 ntype.gpu_fn = file_ns::gpu_shader_rgb;
65 ntype.materialx_fn = file_ns::node_shader_materialx;
66
68}
#define NODE_CLASS_INPUT
Definition BKE_node.hh:447
#define SH_NODE_RGB
bool GPU_link(GPUMaterial *mat, const char *name,...)
GPUNodeLink * GPU_uniform(const float *num)
void uiTemplateColorPicker(uiLayout *layout, PointerRNA *ptr, blender::StringRefNull propname, bool value_slider, bool lock, bool lock_luminosity, bool cubic)
@ UI_ITEM_R_SLIDER
uint col
#define out
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
static void node_declare(NodeDeclarationBuilder &b)
static int gpu_shader_rgb(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *, GPUNodeStack *out)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_rgb()
void sh_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
void * first
void * default_value
ListBase outputs
Defines a node type.
Definition BKE_node.hh:238
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:344
std::string ui_description
Definition BKE_node.hh:244
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:342
const char * enum_name_legacy
Definition BKE_node.hh:247
NodeDeclareFunction declare
Definition BKE_node.hh:362