Blender V5.0
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
5#include "node_shader_util.hh"
6
8#include "UI_resources.hh"
9
11
13{
14 b.add_input<decl::Color>("Color").default_value({0.8f, 0.8f, 0.8f, 1.0f});
15 b.add_input<decl::Float>("Offset").default_value(0.0f).min(-M_PI_2).max(M_PI_2).subtype(
17 b.add_input<decl::Float>("RoughnessU")
18 .default_value(0.1f)
19 .min(0.0f)
20 .max(1.0f)
22 b.add_input<decl::Float>("RoughnessV")
23 .default_value(1.0f)
24 .min(0.0f)
25 .max(1.0f)
27 b.add_input<decl::Vector>("Tangent").hide_value();
28 b.add_input<decl::Float>("Weight").available(false);
29 b.add_output<decl::Shader>("BSDF");
30}
31
32static void node_shader_buts_hair(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
33{
34 layout->prop(ptr, "component", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
35}
36
38 bNode *node,
39 bNodeExecData * /*execdata*/,
42{
44
45 return GPU_stack_link(mat, node, "node_bsdf_hair", in, out);
46}
47
48} // namespace blender::nodes::node_shader_bsdf_hair_cc
49
50/* node type definition */
52{
54
55 static blender::bke::bNodeType ntype;
56
57 sh_node_type_base(&ntype, "ShaderNodeBsdfHair", SH_NODE_BSDF_HAIR);
58 ntype.ui_name = "Hair BSDF";
59 ntype.ui_description = "Reflection and transmission shaders optimized for hair rendering";
60 ntype.enum_name_legacy = "BSDF_HAIR";
62 ntype.declare = file_ns::node_declare;
64 ntype.draw_buttons = file_ns::node_shader_buts_hair;
65 blender::bke::node_type_size(ntype, 150, 60, 200);
66 ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_hair;
67
69}
#define NODE_CLASS_SHADER
Definition BKE_node.hh:460
#define SH_NODE_BSDF_HAIR
#define M_PI_2
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
@ GPU_MATFLAG_DIFFUSE
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
@ PROP_ANGLE
Definition RNA_types.hh:252
@ PROP_FACTOR
Definition RNA_types.hh:251
@ UI_ITEM_R_SPLIT_EMPTY_NAME
#define in
#define out
void node_type_size(bNodeType &ntype, int width, int minwidth, int maxwidth)
Definition node.cc:5384
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
static void node_declare(NodeDeclarationBuilder &b)
static void node_shader_buts_hair(uiLayout *layout, bContext *, PointerRNA *ptr)
static int node_shader_gpu_bsdf_hair(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
void register_node_type_sh_bsdf_hair()
void sh_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
bool object_cycles_shader_nodes_poll(const bContext *C)
Defines a node type.
Definition BKE_node.hh:238
std::string ui_description
Definition BKE_node.hh:244
bool(* add_ui_poll)(const bContext *C)
Definition BKE_node.hh:310
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:342
const char * enum_name_legacy
Definition BKE_node.hh:247
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:259
NodeDeclareFunction declare
Definition BKE_node.hh:362
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)
PointerRNA * ptr
Definition wm_files.cc:4238