Blender V5.0
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
5#include "node_shader_util.hh"
6
8
10{
11 b.add_input<decl::Float>("Blend").default_value(0.5f).min(0.0f).max(1.0f);
12 b.add_input<decl::Vector>("Normal").hide_value();
13 b.add_output<decl::Float>("Fresnel");
14 b.add_output<decl::Float>("Facing");
15}
16
18 bNode *node,
19 bNodeExecData * /*execdata*/,
22{
23 if (!in[1].link) {
24 GPU_link(mat, "world_normals_get", &in[1].link);
25 }
26
27 return GPU_stack_link(mat, node, "node_layer_weight", in, out);
28}
29
31#ifdef WITH_MATERIALX
32{
33 /* TODO: some outputs expected be implemented partially within the next iteration
34 * (see node-definition `<artistic_ior>`). */
35 return get_input_link("Blend", NodeItem::Type::Float);
36}
37#endif
39
40} // namespace blender::nodes::node_shader_layer_weight_cc
41
42/* node type definition */
44{
46
47 static blender::bke::bNodeType ntype;
48
49 sh_node_type_base(&ntype, "ShaderNodeLayerWeight", SH_NODE_LAYER_WEIGHT);
50 ntype.ui_name = "Layer Weight";
51 ntype.ui_description =
52 "Produce a blending factor depending on the angle between the surface normal and the view "
53 "direction.\nTypically used for layering shaders with the Mix Shader node";
54 ntype.enum_name_legacy = "LAYER_WEIGHT";
56 ntype.declare = file_ns::node_declare;
57 ntype.gpu_fn = file_ns::node_shader_gpu_layer_weight;
58 ntype.materialx_fn = file_ns::node_shader_materialx;
59
61}
#define NODE_CLASS_INPUT
Definition BKE_node.hh:447
#define SH_NODE_LAYER_WEIGHT
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
bool GPU_link(GPUMaterial *mat, const char *name,...)
#define in
#define out
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
static int node_shader_gpu_layer_weight(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_layer_weight()
void sh_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
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
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:342
const char * enum_name_legacy
Definition BKE_node.hh:247
NodeDeclareFunction declare
Definition BKE_node.hh:362