Blender V5.3
node_shader_light_path.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_output<decl::Float>("Is Camera Ray"_ustr);
18 b.add_output<decl::Float>("Is Shadow Ray"_ustr);
19 b.add_output<decl::Float>("Is Diffuse Ray"_ustr);
20 b.add_output<decl::Float>("Is Glossy Ray"_ustr);
21 b.add_output<decl::Float>("Is Singular Ray"_ustr);
22 b.add_output<decl::Float>("Is Reflection Ray"_ustr);
23 b.add_output<decl::Float>("Is Transmission Ray"_ustr);
24 b.add_output<decl::Float>("Is Volume Scatter Ray"_ustr);
25 b.add_output<decl::Float>("Ray Length"_ustr);
26 b.add_output<decl::Float>("Ray Depth"_ustr);
27 b.add_output<decl::Float>("Diffuse Depth"_ustr);
28 b.add_output<decl::Float>("Glossy Depth"_ustr);
29 b.add_output<decl::Float>("Transparent Depth"_ustr);
30 b.add_output<decl::Float>("Transmission Depth"_ustr);
31 b.add_output<decl::Float>("Portal Depth"_ustr);
32}
33
35 bNode *node,
36 bNodeExecData * /*execdata*/,
39{
40 if (out[2].hasoutput || /* Is Diffuse Ray. */
41 out[3].hasoutput || /* Is Glossy Ray. */
42 out[4].hasoutput || /* Is Singular Ray. */
43 out[5].hasoutput || /* Is Reflection Ray. */
44 out[6].hasoutput || /* Is Transmission Ray. */
45 out[10].hasoutput || /* Diffuse Depth. */
46 out[11].hasoutput || /* Glossy Depth. */
47 out[13].hasoutput) /* Transmission Depth. */
48 {
49 /* Used to detect that the world has a specific look for diffuse path. */
51 }
52 return GPU_stack_link(mat, node, "node_light_path", in, out, GPU_shading_data());
53}
54
56#ifdef WITH_MATERIALX
57{
58 /* NOTE: This node isn't supported by MaterialX. Only default values returned. */
59 if (STREQ(socket_out_->identifier, "Is Camera Ray")) {
60 return val(1.0f);
61 }
62 if (STREQ(socket_out_->identifier, "Ray Length")) {
63 return val(1.0f);
64 }
65 NodeItem res = val(0.0f);
66 return res;
67}
68#endif
70
71} // namespace nodes::node_shader_light_path_cc
72
73/* node type definition */
75{
76 namespace file_ns = nodes::node_shader_light_path_cc;
77
78 static bke::bNodeType ntype;
79
80 sh_node_type_base(&ntype, "ShaderNodeLightPath"_ustr, SH_NODE_LIGHT_PATH);
81 ntype.ui_name = "Light Path";
82 ntype.ui_description =
83 "Retrieve the type of incoming ray for which the shader is being executed.\nTypically used "
84 "for non-physically-based tricks";
85 ntype.enum_name_legacy = "LIGHT_PATH";
87 ntype.declare = file_ns::node_declare;
88 ntype.gpu_fn = file_ns::node_shader_gpu_light_path;
89 ntype.materialx_fn = file_ns::node_shader_materialx;
90
92}
93
94} // namespace blender
#define NODE_CLASS_INPUT
Definition BKE_node.hh:478
#define SH_NODE_LIGHT_PATH
#define STREQ(a, b)
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static void node_declare(NodeDeclarationBuilder &b)
static int node_shader_gpu_light_path(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
BMesh Iterators.
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
@ GPU_MATFLAG_IS_DIFFUSE_OR_GLOSSY_RAY_FLAG
void register_node_type_sh_light_path()
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
GPUNodeLink * GPU_shading_data()
#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