Blender V5.0
node_shader_bsdf_sheen.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>("Roughness")
16 .default_value(0.5f)
17 .min(0.0f)
18 .max(1.0f)
20 b.add_input<decl::Vector>("Normal").hide_value();
21 b.add_input<decl::Float>("Weight").available(false);
22 b.add_output<decl::Shader>("BSDF");
23}
24
25static void node_shader_buts_sheen(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
26{
27 layout->prop(ptr, "distribution", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
28}
29
30static void node_shader_init_sheen(bNodeTree * /*ntree*/, bNode *node)
31{
33}
34
36 bNode *node,
37 bNodeExecData * /*execdata*/,
40{
41 if (!in[2].link) {
42 GPU_link(mat, "world_normals_get", &in[2].link);
43 }
44
46
47 return GPU_stack_link(mat, node, "node_bsdf_sheen", in, out);
48}
49
51#ifdef WITH_MATERIALX
52{
53 if (to_type_ != NodeItem::Type::BSDF) {
54 return empty();
55 }
56
57 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
58 NodeItem roughness = get_input_value("Roughness", NodeItem::Type::Float);
59 NodeItem normal = get_input_link("Normal", NodeItem::Type::Vector3);
60# if !(MATERIALX_MAJOR_VERSION <= 1 && MATERIALX_MINOR_VERSION <= 38)
61 NodeItem mode = node_->custom1 == SHD_SHEEN_MICROFIBER ? val(std::string("zeltner")) :
62 val(std::string("conty_kulla"));
63# endif
64
65 return create_node("sheen_bsdf",
66 NodeItem::Type::BSDF,
67 {{"color", color},
68 {"roughness", roughness},
69 {"normal", normal}
70# if !(MATERIALX_MAJOR_VERSION <= 1 && MATERIALX_MINOR_VERSION <= 38)
71 ,
72 {"mode", mode}});
73# else
74 });
75# endif
76}
77#endif
79
80} // namespace blender::nodes::node_shader_bsdf_sheen_cc
81
82/* node type definition */
84{
86
87 static blender::bke::bNodeType ntype;
88
89 sh_node_type_base(&ntype, "ShaderNodeBsdfSheen", SH_NODE_BSDF_SHEEN);
90 ntype.ui_name = "Sheen BSDF";
91 ntype.ui_description =
92 "Reflection for materials such as cloth.\nTypically mixed with other shaders (such as a "
93 "Diffuse Shader) and is not particularly useful on its own";
94 ntype.enum_name_legacy = "BSDF_SHEEN";
97 ntype.declare = file_ns::node_declare;
98 ntype.initfunc = file_ns::node_shader_init_sheen;
99 ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_sheen;
100 ntype.draw_buttons = file_ns::node_shader_buts_sheen;
101 ntype.materialx_fn = file_ns::node_shader_materialx;
102
104}
#define NODE_CLASS_SHADER
Definition BKE_node.hh:460
#define SH_NODE_BSDF_SHEEN
#define SHD_SHEEN_MICROFIBER
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)
bool GPU_link(GPUMaterial *mat, const char *name,...)
@ PROP_FACTOR
Definition RNA_types.hh:251
@ UI_ITEM_R_SPLIT_EMPTY_NAME
#define in
#define out
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
static void node_declare(NodeDeclarationBuilder &b)
static void node_shader_buts_sheen(uiLayout *layout, bContext *, PointerRNA *ptr)
static int node_shader_gpu_bsdf_sheen(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_shader_init_sheen(bNodeTree *, bNode *node)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_bsdf_sheen()
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)
int16_t custom1
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
bool(* add_ui_poll)(const bContext *C)
Definition BKE_node.hh:310
void(* initfunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:289
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