Blender V4.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
9#include "node_shader_util.hh"
10
12
14{
15 b.add_input<decl::Float>("Fac")
16 .default_value(1.0f)
17 .min(0.0f)
18 .max(1.0f)
20 .description("Amount of influence the node exerts on the image");
21 b.add_input<decl::Color>("Color")
22 .default_value({0.0f, 0.0f, 0.0f, 1.0f})
23 .description("Color input on which invertion will be applied");
24 b.add_output<decl::Color>("Color");
25}
26
28 bNode *node,
29 bNodeExecData * /*execdata*/,
30 GPUNodeStack *in,
31 GPUNodeStack *out)
32{
33 return GPU_stack_link(mat, node, "invert", in, out);
34}
35
37#ifdef WITH_MATERIALX
38{
39 NodeItem fac = get_input_value("Fac", NodeItem::Type::Float);
40 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
41 return fac.mix(color, val(1.0f) - color);
42}
43#endif
45
46} // namespace blender::nodes::node_shader_invert_cc
47
49{
50 namespace file_ns = blender::nodes::node_shader_invert_cc;
51
52 static blender::bke::bNodeType ntype;
53
55 ntype.declare = file_ns::node_declare;
56 ntype.gpu_fn = file_ns::gpu_shader_invert;
57 ntype.materialx_fn = file_ns::node_shader_materialx;
58
60}
#define SH_NODE_INVERT
Definition BKE_node.hh:908
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:406
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
@ PROP_FACTOR
Definition RNA_types.hh:154
local_group_size(16, 16) .push_constant(Type b
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
static int gpu_shader_invert(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_declare(NodeDeclarationBuilder &b)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_invert()
void sh_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
Defines a node type.
Definition BKE_node.hh:218
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:320
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:318
NodeDeclareFunction declare
Definition BKE_node.hh:347