Blender V4.3
node_shader_value.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
11#include "FN_multi_function.hh"
13
14#include "NOD_multi_function.hh"
15
17
19{
20 b.add_output<decl::Float>("Value");
21}
22
24 bNode *node,
25 bNodeExecData * /*execdata*/,
26 GPUNodeStack * /*in*/,
27 GPUNodeStack *out)
28{
29 const bNodeSocket *socket = static_cast<bNodeSocket *>(node->outputs.first);
30 float value = static_cast<bNodeSocketValueFloat *>(socket->default_value)->value;
31 return GPU_link(mat, "set_value", GPU_uniform(&value), &out->link);
32}
33
40
42#ifdef WITH_MATERIALX
43{
44 NodeItem value = get_output_default("Value", NodeItem::Type::Float);
45 return create_node("constant", NodeItem::Type::Float, {{"value", value}});
46}
47#endif
49
50} // namespace blender::nodes::node_shader_value_cc
51
53{
54 namespace file_ns = blender::nodes::node_shader_value_cc;
55
56 static blender::bke::bNodeType ntype;
57
59 ntype.declare = file_ns::sh_node_value_declare;
60 ntype.gpu_fn = file_ns::gpu_shader_value;
61 ntype.build_multi_function = file_ns::sh_node_value_build_multi_function;
62 ntype.materialx_fn = file_ns::node_shader_materialx;
63
65}
#define SH_NODE_VALUE
Definition BKE_node.hh:892
#define NODE_CLASS_INPUT
Definition BKE_node.hh:404
bool GPU_link(GPUMaterial *mat, const char *name,...)
GPUNodeLink * GPU_uniform(const float *num)
local_group_size(16, 16) .push_constant(Type b
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
static int gpu_shader_value(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *, GPUNodeStack *out)
static void sh_node_value_declare(NodeDeclarationBuilder &b)
static void sh_node_value_build_multi_function(NodeMultiFunctionBuilder &builder)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void sh_fn_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
void register_node_type_sh_value()
void * first
void * default_value
ListBase outputs
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
NodeMultiFunctionBuildFunction build_multi_function
Definition BKE_node.hh:336
NodeDeclareFunction declare
Definition BKE_node.hh:347