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