Blender V5.0
node_shader_hair_info.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
5#include "node_shader_util.hh"
6
8
10{
11 b.add_output<decl::Float>("Is Strand");
12#define INTERCEPT_SOCKET_INDEX 1
13 b.add_output<decl::Float>("Intercept");
14#define LENGTH_SOCKET_INDEX 2
15 b.add_output<decl::Float>("Length");
16 b.add_output<decl::Float>("Thickness");
17 b.add_output<decl::Vector>("Tangent Normal");
18 b.add_output<decl::Float>("Random");
19}
20
22 bNode *node,
23 bNodeExecData * /*execdata*/,
26{
27 /* Length: don't request length if not needed. */
28 static const float zero = 0;
29 GPUNodeLink *length_link = out[LENGTH_SOCKET_INDEX].hasoutput ? GPU_attribute_hair_length(mat) :
30 GPU_constant(&zero);
31 GPUNodeLink *intercept_link = out[INTERCEPT_SOCKET_INDEX].hasoutput ?
33 GPU_constant(&zero);
34 return GPU_stack_link(mat, node, "node_hair_info", in, out, intercept_link, length_link);
35}
36
38#ifdef WITH_MATERIALX
39{
40 /* NOTE: This node doesn't have an implementation in MaterialX. */
41 return get_output_default(socket_out_->identifier, NodeItem::Type::Any);
42}
43#endif
45
46} // namespace blender::nodes::node_shader_hair_info_cc
47
48/* node type definition */
50{
52
53 static blender::bke::bNodeType ntype;
54
55 sh_node_type_base(&ntype, "ShaderNodeHairInfo", SH_NODE_HAIR_INFO);
56 ntype.ui_name = "Curves Info";
57 ntype.ui_description = "Retrieve hair curve information";
58 ntype.enum_name_legacy = "HAIR_INFO";
60 ntype.declare = file_ns::node_declare;
61 ntype.gpu_fn = file_ns::node_shader_gpu_hair_info;
62 ntype.materialx_fn = file_ns::node_shader_materialx;
63
65}
#define NODE_CLASS_INPUT
Definition BKE_node.hh:447
#define SH_NODE_HAIR_INFO
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
GPUNodeLink * GPU_constant(const float *num)
GPUNodeLink * GPU_attribute_hair_length(GPUMaterial *mat)
GPUNodeLink * GPU_attribute_hair_intercept(GPUMaterial *mat)
#define in
#define out
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
static void node_declare(NodeDeclarationBuilder &b)
static int node_shader_gpu_hair_info(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_hair_info()
#define LENGTH_SOCKET_INDEX
#define INTERCEPT_SOCKET_INDEX
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