Blender V4.3
node_shader_bsdf_diffuse.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
10{
11 b.add_input<decl::Color>("Color").default_value({0.8f, 0.8f, 0.8f, 1.0f});
12 b.add_input<decl::Float>("Roughness")
13 .default_value(0.0f)
14 .min(0.0f)
15 .max(1.0f)
17 b.add_input<decl::Vector>("Normal").hide_value();
18 b.add_input<decl::Float>("Weight").available(false);
19 b.add_output<decl::Shader>("BSDF");
20}
21
23 bNode *node,
24 bNodeExecData * /*execdata*/,
25 GPUNodeStack *in,
26 GPUNodeStack *out)
27{
28 if (!in[2].link) {
29 GPU_link(mat, "world_normals_get", &in[2].link);
30 }
31
33
34 return GPU_stack_link(mat, node, "node_bsdf_diffuse", in, out);
35}
36
38#ifdef WITH_MATERIALX
39{
40 if (to_type_ != NodeItem::Type::BSDF) {
41 return empty();
42 }
43
44 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
45 NodeItem roughness = get_input_value("Roughness", NodeItem::Type::Float);
46 NodeItem normal = get_input_link("Normal", NodeItem::Type::Vector3);
47
48 return create_node("oren_nayar_diffuse_bsdf",
49 NodeItem::Type::BSDF,
50 {{"color", color}, {"roughness", roughness}, {"normal", normal}});
51}
52#endif
54
55} // namespace blender::nodes::node_shader_bsdf_diffuse_cc
56
57/* node type definition */
59{
61
62 static blender::bke::bNodeType ntype;
63
64 sh_node_type_base(&ntype, SH_NODE_BSDF_DIFFUSE, "Diffuse BSDF", NODE_CLASS_SHADER);
65 ntype.declare = file_ns::node_declare;
68 ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_diffuse;
69 ntype.materialx_fn = file_ns::node_shader_materialx;
70
72}
#define NODE_CLASS_SHADER
Definition BKE_node.hh:417
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
local_group_size(16, 16) .push_constant(Type b
void node_type_size_preset(bNodeType *ntype, eNodeSizePreset size)
Definition node.cc:4614
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
static int node_shader_gpu_bsdf_diffuse(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_declare(NodeDeclarationBuilder &b)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_bsdf_diffuse()
void sh_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
bool object_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
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:318
NodeDeclareFunction declare
Definition BKE_node.hh:347