Blender V4.5
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}
26
28 bNode *node,
29 bNodeExecData * /*execdata*/,
32{
33 return GPU_stack_link(mat, node, "node_light_path", in, out);
34}
35
37#ifdef WITH_MATERIALX
38{
39 /* NOTE: This node isn't supported by MaterialX. Only default values returned. */
40 if (STREQ(socket_out_->name, "Is Camera Ray")) {
41 return val(1.0f);
42 }
43 if (STREQ(socket_out_->name, "Ray Length")) {
44 return val(1.0f);
45 }
46 NodeItem res = val(0.0f);
47 return res;
48}
49#endif
51
52} // namespace blender::nodes::node_shader_light_path_cc
53
54/* node type definition */
56{
58
59 static blender::bke::bNodeType ntype;
60
61 sh_node_type_base(&ntype, "ShaderNodeLightPath", SH_NODE_LIGHT_PATH);
62 ntype.ui_name = "Light Path";
63 ntype.ui_description =
64 "Retrieve the type of incoming ray for which the shader is being executed.\nTypically used "
65 "for non-physically-based tricks";
66 ntype.enum_name_legacy = "LIGHT_PATH";
68 ntype.declare = file_ns::node_declare;
69 ntype.gpu_fn = file_ns::node_shader_gpu_light_path;
70 ntype.materialx_fn = file_ns::node_shader_materialx;
71
73}
#define NODE_CLASS_INPUT
Definition BKE_node.hh:433
#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:2748
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:226
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:332
std::string ui_description
Definition BKE_node.hh:232
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:330
const char * enum_name_legacy
Definition BKE_node.hh:235
NodeDeclareFunction declare
Definition BKE_node.hh:355