Blender V5.3
node_shader_bsdf_hair.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
12#include "UI_resources.hh"
13
14namespace blender {
15
17
19{
20 const bNodeTree *ntree = b.tree_or_null();
21 const bool is_gpu_internal = ntree && (ntree->flag & NTREE_IS_GPU_SHADER_INTERNAL);
22
23 b.add_input<decl::Color>("Color"_ustr).default_value({0.8f, 0.8f, 0.8f, 1.0f});
24 b.add_input<decl::Float>("Offset"_ustr)
25 .default_value(0.0f)
26 .min(-M_PI_2)
27 .max(M_PI_2)
29 b.add_input<decl::Float>("RoughnessU"_ustr)
30 .default_value(0.1f)
31 .min(0.0f)
32 .max(1.0f)
34 b.add_input<decl::Float>("RoughnessV"_ustr)
35 .default_value(1.0f)
36 .min(0.0f)
37 .max(1.0f)
39 b.add_input<decl::Vector>("Tangent"_ustr).hide_value();
40 b.add_input<decl::Float>("Weight"_ustr).available(is_gpu_internal);
41 b.add_output<decl::Shader>("BSDF"_ustr);
42}
43
44static void node_shader_buts_hair(ui::Layout &layout, bContext * /*C*/, PointerRNA *ptr)
45{
46 layout.prop(ptr, "component", ui::ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
47}
48
50 bNode *node,
51 bNodeExecData * /*execdata*/,
54{
56
57 return GPU_stack_link(
58 mat, node, "node_bsdf_hair", in, out, GPU_kernel_globals(), GPU_shading_data());
59}
60
61} // namespace nodes::node_shader_bsdf_hair_cc
62
63/* node type definition */
65{
66 namespace file_ns = nodes::node_shader_bsdf_hair_cc;
67
68 static bke::bNodeType ntype;
69
70 sh_node_type_base(&ntype, "ShaderNodeBsdfHair"_ustr, SH_NODE_BSDF_HAIR);
71 ntype.ui_name = "Hair BSDF";
72 ntype.ui_description = "Reflection and transmission shaders optimized for hair rendering";
73 ntype.enum_name_legacy = "BSDF_HAIR";
75 ntype.declare = file_ns::node_declare;
78 ntype.draw_buttons = file_ns::node_shader_buts_hair;
80 ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_hair;
81
83}
84
85} // namespace blender
#define NODE_CLASS_SHADER
Definition BKE_node.hh:491
#define SH_NODE_BSDF_HAIR
#define M_PI_2
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static void node_declare(NodeDeclarationBuilder &b)
static void node_shader_buts_hair(ui::Layout &layout, bContext *, PointerRNA *ptr)
static int node_shader_gpu_bsdf_hair(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,...)
bool object_cycles_shader_nodes_poll(const bContext *C)
@ GPU_MATFLAG_DIFFUSE
void register_node_type_sh_bsdf_hair()
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
void search_link_ops_for_shader_bsdf_node(nodes::GatherLinkSearchOpParams &params)
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
GPUNodeLink * GPU_shading_data()
@ NTREE_IS_GPU_SHADER_INTERNAL
GPUNodeLink * GPU_kernel_globals()
@ PROP_FACTOR
Definition RNA_types.hh:308
eNodeTree_Flag flag
static constexpr int _160
Definition BKE_node.hh:246
Defines a node type.
Definition BKE_node.hh:265
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:290
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
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
Definition BKE_node.hh:409
NodeDeclareFunction declare
Definition BKE_node.hh:393
bool(*) add_ui_poll(const bContext *C)
Definition BKE_node.hh:341
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)