Blender V5.3
node_shader_layer_weight.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
11namespace blender {
12
14
16{
17 b.add_input<decl::Float>("Blend"_ustr).default_value(0.5f).min(0.0f).max(1.0f);
18 b.add_input<decl::Vector>("Normal"_ustr).hide_value();
19 b.add_output<decl::Float>("Fresnel"_ustr);
20 b.add_output<decl::Float>("Facing"_ustr);
21}
22
24 bNode *node,
25 bNodeExecData * /*execdata*/,
28{
29 if (!in[1].link) {
30 GPU_link(mat, "world_normals_get", GPU_shading_data(), &in[1].link);
31 }
32
33 return GPU_stack_link(
34 mat, node, "node_layer_weight", in, out, GPU_kernel_globals(), GPU_shading_data());
35}
36
38#ifdef WITH_MATERIALX
39{
40 /* TODO: some outputs expected be implemented partially within the next iteration
41 * (see node-definition `<artistic_ior>`). */
42 return get_input_link("Blend", NodeItem::Type::Float);
43}
44#endif
46
47} // namespace nodes::node_shader_layer_weight_cc
48
49/* node type definition */
51{
52 namespace file_ns = nodes::node_shader_layer_weight_cc;
53
54 static bke::bNodeType ntype;
55
56 sh_node_type_base(&ntype, "ShaderNodeLayerWeight"_ustr, SH_NODE_LAYER_WEIGHT);
57 ntype.ui_name = "Layer Weight";
58 ntype.ui_description =
59 "Produce a blending factor depending on the angle between the surface normal and the view "
60 "direction.\nTypically used for layering shaders with the Mix Shader node";
61 ntype.enum_name_legacy = "LAYER_WEIGHT";
63 ntype.declare = file_ns::node_declare;
64 ntype.gpu_fn = file_ns::node_shader_gpu_layer_weight;
65 ntype.materialx_fn = file_ns::node_shader_materialx;
66
68}
69
70} // namespace blender
#define NODE_CLASS_INPUT
Definition BKE_node.hh:478
#define SH_NODE_LAYER_WEIGHT
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static int node_shader_gpu_layer_weight(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_declare(NodeDeclarationBuilder &b)
BMesh Iterators.
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
void register_node_type_sh_layer_weight()
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
bool GPU_link(GPUMaterial *mat, const char *name,...)
GPUNodeLink * GPU_shading_data()
GPUNodeLink * GPU_kernel_globals()
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
Defines a node type.
Definition BKE_node.hh:265
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:375
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
NodeDeclareFunction declare
Definition BKE_node.hh:393