Blender V5.0
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
16
18{
19 b.add_input<decl::Color>("Color").default_value({0.5f, 0.5f, 0.5f, 1.0f});
20 b.add_output<decl::Float>("Val");
21}
22
24 bNode *node,
25 bNodeExecData * /*execdata*/,
28{
29 float coefficients[3];
31 return GPU_stack_link(mat, node, "rgbtobw", in, out, GPU_constant(coefficients));
32}
33
35#ifdef WITH_MATERIALX
36{
37 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
38 return create_node("luminance", NodeItem::Type::Color3, {{"in", color}});
39}
40#endif
42
43} // namespace blender::nodes::node_shader_rgb_to_bw_cc
44
46{
48
49 static blender::bke::bNodeType ntype;
50
51 sh_node_type_base(&ntype, "ShaderNodeRGBToBW", SH_NODE_RGBTOBW);
52 ntype.ui_name = "RGB to BW";
53 ntype.ui_description = "Convert a color's luminance to a grayscale value";
54 ntype.enum_name_legacy = "RGBTOBW";
56 ntype.declare = file_ns::sh_node_rgbtobw_declare;
57 ntype.gpu_fn = file_ns::gpu_shader_rgbtobw;
58 ntype.materialx_fn = file_ns::node_shader_materialx;
59
61}
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:453
#define SH_NODE_RGBTOBW
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
GPUNodeLink * GPU_constant(const float *num)
BLI_INLINE void IMB_colormanagement_get_luminance_coefficients(float r_rgb[3])
#define in
#define out
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
static void sh_node_rgbtobw_declare(NodeDeclarationBuilder &b)
static int gpu_shader_rgbtobw(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_rgbtobw()
void sh_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
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