Blender V4.3
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
7#include "UI_interface.hh"
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 uiItemR(layout, ptr, "distribution", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
28}
29
30static void node_shader_init_sheen(bNodeTree * /*ntree*/, bNode *node)
31{
32 node->custom1 = SHD_SHEEN_MICROFIBER;
33}
34
36 bNode *node,
37 bNodeExecData * /*execdata*/,
38 GPUNodeStack *in,
39 GPUNodeStack *out)
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
61 return create_node("sheen_bsdf",
62 NodeItem::Type::BSDF,
63 {{"color", color}, {"roughness", roughness}, {"normal", normal}});
64}
65#endif
67
68} // namespace blender::nodes::node_shader_bsdf_sheen_cc
69
70/* node type definition */
72{
74
75 static blender::bke::bNodeType ntype;
76
77 sh_node_type_base(&ntype, SH_NODE_BSDF_SHEEN, "Sheen BSDF", NODE_CLASS_SHADER);
79 ntype.declare = file_ns::node_declare;
80 ntype.initfunc = file_ns::node_shader_init_sheen;
81 ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_sheen;
82 ntype.draw_buttons = file_ns::node_shader_buts_sheen;
83 ntype.materialx_fn = file_ns::node_shader_materialx;
84
86}
#define NODE_CLASS_SHADER
Definition BKE_node.hh:417
#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:154
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
local_group_size(16, 16) .push_constant(Type b
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
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, int type, const char *name, short nclass)
bool object_cycles_shader_nodes_poll(const bContext *C)
Defines a node type.
Definition BKE_node.hh:218
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:320
bool(* add_ui_poll)(const bContext *C)
Definition BKE_node.hh:288
void(* initfunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:267
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:318
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:238
NodeDeclareFunction declare
Definition BKE_node.hh:347
PointerRNA * ptr
Definition wm_files.cc:4126