Blender V5.3
node_shader_invert.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
11namespace blender {
12
14
16{
17 b.add_input<decl::Float>("Factor"_ustr, "Fac"_ustr)
18 .default_value(1.0f)
19 .min(0.0f)
20 .max(1.0f)
22 .description("Amount of influence the node exerts on the image");
23 b.add_input<decl::Color>("Color"_ustr)
24 .default_value({0.0f, 0.0f, 0.0f, 1.0f})
25 .description("Color input on which inversion will be applied");
26 b.add_output<decl::Color>("Color"_ustr);
27}
28
30 bNode *node,
31 bNodeExecData * /*execdata*/,
34{
35 return GPU_stack_link(mat, node, "invert", in, out);
36}
37
39#ifdef WITH_MATERIALX
40{
41 NodeItem fac = get_input_value("Fac", NodeItem::Type::Float);
42 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
43 return fac.mix(color, val(1.0f) - color);
44}
45#endif
47
48} // namespace nodes::node_shader_invert_cc
49
51{
52 namespace file_ns = nodes::node_shader_invert_cc;
53
54 static bke::bNodeType ntype;
55
56 sh_node_type_base(&ntype, "ShaderNodeInvert"_ustr, SH_NODE_INVERT);
57 ntype.ui_name = "Invert Color";
58 ntype.ui_description = "Invert a color, producing a negative";
59 ntype.enum_name_legacy = "INVERT";
61 ntype.declare = file_ns::node_declare;
62 ntype.gpu_fn = file_ns::gpu_shader_invert;
63 ntype.materialx_fn = file_ns::node_shader_materialx;
64
66}
67
68} // namespace blender
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:480
#define SH_NODE_INVERT
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static int gpu_shader_invert(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_declare(NodeDeclarationBuilder &b)
BMesh Iterators.
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
void register_node_type_sh_invert()
@ PROP_FACTOR
Definition RNA_types.hh:308
#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