Blender V5.3
node_shader_rgb_to_bw.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 "GPU_material.hh"
10
12
13#include "node_shader_util.hh"
14
15namespace blender {
16
18
20{
21 b.add_input<decl::Color>("Color"_ustr).default_value({0.5f, 0.5f, 0.5f, 1.0f});
22 b.add_output<decl::Float>("Val"_ustr);
23}
24
26 bNode *node,
27 bNodeExecData * /*execdata*/,
30{
31 float coefficients[3];
33 return GPU_stack_link(mat, node, "rgbtobw", in, out, GPU_constant(coefficients));
34}
35
37#ifdef WITH_MATERIALX
38{
39 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
40 return create_node("luminance", NodeItem::Type::Color3, {{"in", color}});
41}
42#endif
44
45} // namespace nodes::node_shader_rgb_to_bw_cc
46
48{
49 namespace file_ns = nodes::node_shader_rgb_to_bw_cc;
50
51 static bke::bNodeType ntype;
52
53 sh_node_type_base(&ntype, "ShaderNodeRGBToBW"_ustr, SH_NODE_RGBTOBW);
54 ntype.ui_name = "RGB to BW";
55 ntype.ui_description = "Convert a color's luminance to a grayscale value";
56 ntype.enum_name_legacy = "RGBTOBW";
58 ntype.declare = file_ns::sh_node_rgbtobw_declare;
59 ntype.gpu_fn = file_ns::gpu_shader_rgbtobw;
60 ntype.materialx_fn = file_ns::node_shader_materialx;
61
63}
64
65} // namespace blender
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:484
#define SH_NODE_RGBTOBW
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static void sh_node_rgbtobw_declare(NodeDeclarationBuilder &b)
static int gpu_shader_rgbtobw(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
BMesh Iterators.
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
BLI_INLINE void IMB_colormanagement_get_luminance_coefficients(float r_rgb[3])
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
GPUNodeLink * GPU_constant(const float *num)
void register_node_type_sh_rgbtobw()
#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