Blender V5.0
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
5#include "node_shader_util.hh"
6
8
10{
11 b.add_output<decl::Float>("Is Camera Ray");
12 b.add_output<decl::Float>("Is Shadow Ray");
13 b.add_output<decl::Float>("Is Diffuse Ray");
14 b.add_output<decl::Float>("Is Glossy Ray");
15 b.add_output<decl::Float>("Is Singular Ray");
16 b.add_output<decl::Float>("Is Reflection Ray");
17 b.add_output<decl::Float>("Is Transmission Ray");
18 b.add_output<decl::Float>("Is Volume Scatter Ray");
19 b.add_output<decl::Float>("Ray Length");
20 b.add_output<decl::Float>("Ray Depth");
21 b.add_output<decl::Float>("Diffuse Depth");
22 b.add_output<decl::Float>("Glossy Depth");
23 b.add_output<decl::Float>("Transparent Depth");
24 b.add_output<decl::Float>("Transmission Depth");
25 b.add_output<decl::Float>("Portal Depth");
26}
27
29 bNode *node,
30 bNodeExecData * /*execdata*/,
33{
34 return GPU_stack_link(mat, node, "node_light_path", in, out);
35}
36
38#ifdef WITH_MATERIALX
39{
40 /* NOTE: This node isn't supported by MaterialX. Only default values returned. */
41 if (STREQ(socket_out_->identifier, "Is Camera Ray")) {
42 return val(1.0f);
43 }
44 if (STREQ(socket_out_->identifier, "Ray Length")) {
45 return val(1.0f);
46 }
47 NodeItem res = val(0.0f);
48 return res;
49}
50#endif
52
53} // namespace blender::nodes::node_shader_light_path_cc
54
55/* node type definition */
57{
59
60 static blender::bke::bNodeType ntype;
61
62 sh_node_type_base(&ntype, "ShaderNodeLightPath", SH_NODE_LIGHT_PATH);
63 ntype.ui_name = "Light Path";
64 ntype.ui_description =
65 "Retrieve the type of incoming ray for which the shader is being executed.\nTypically used "
66 "for non-physically-based tricks";
67 ntype.enum_name_legacy = "LIGHT_PATH";
69 ntype.declare = file_ns::node_declare;
70 ntype.gpu_fn = file_ns::node_shader_gpu_light_path;
71 ntype.materialx_fn = file_ns::node_shader_materialx;
72
74}
#define NODE_CLASS_INPUT
Definition BKE_node.hh:447
#define SH_NODE_LIGHT_PATH
#define STREQ(a, b)
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
#define in
#define out
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
static void node_declare(NodeDeclarationBuilder &b)
static int node_shader_gpu_light_path(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_light_path()
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