Blender V5.3
node_shader_fresnel.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>("IOR"_ustr).default_value(1.5f).min(0.0f).max(1000.0f);
18 b.add_input<decl::Vector>("Normal"_ustr).hide_value();
19 b.add_output<decl::Float>("Factor"_ustr, "Fac"_ustr);
20}
21
23 bNode *node,
24 bNodeExecData * /*execdata*/,
27{
28 if (!in[1].link) {
29 GPU_link(mat, "world_normals_get", GPU_shading_data(), &in[1].link);
30 }
31
32 return GPU_stack_link(
33 mat, node, "node_fresnel", in, out, GPU_kernel_globals(), GPU_shading_data());
34}
35
37#ifdef WITH_MATERIALX
38{
39 /* TODO: some outputs expected be implemented within the next iteration
40 * (see node-definition `<artistic_ior>`). */
41 return get_input_value("IOR", NodeItem::Type::Float);
42}
43#endif
45
46} // namespace nodes::node_shader_fresnel_cc
47
48/* node type definition */
50{
51 namespace file_ns = nodes::node_shader_fresnel_cc;
52
53 static bke::bNodeType ntype;
54
55 sh_node_type_base(&ntype, "ShaderNodeFresnel"_ustr, SH_NODE_FRESNEL);
56 ntype.ui_name = "Fresnel";
57 ntype.ui_description =
58 "Produce a blending factor depending on the angle between the surface normal and the view "
59 "direction using Fresnel equations.\nTypically used for mixing reflections at grazing "
60 "angles";
61 ntype.enum_name_legacy = "FRESNEL";
63 ntype.declare = file_ns::node_declare;
64 ntype.gpu_fn = file_ns::node_shader_gpu_fresnel;
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_FRESNEL
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static int node_shader_gpu_fresnel(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 sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
void register_node_type_sh_fresnel()
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