Blender V5.3
node_shader_light_info.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 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.use_custom_socket_order();
18 b.allow_any_socket_order();
19
20 const bNodeTree *ntree = b.tree_or_null();
21 const bool is_gpu_internal = ntree && (ntree->flag & NTREE_IS_GPU_SHADER_INTERNAL);
22
23 b.add_input<decl::Int>("LightIndex"_ustr).available(is_gpu_internal);
24
25 b.add_output<decl::Color>("Color"_ustr).description("Light color");
26 b.add_output<decl::Float>("Power"_ustr).description("Radiant intensity divided by PI");
27 b.add_output<decl::Vector>("Position"_ustr).description("Light position");
28}
29
31 bNode *node,
32 bNodeExecData * /*execdata*/,
35{
36 if (!in[0].link) {
37 /* Error: not linked to a light accumulation zone. */
39 return false;
40 }
41
42 return GPU_stack_link(mat, node, "node_light_info", in, out, GPU_kernel_globals());
43}
44
45} // namespace nodes::node_shader_light_info_cc
46
47/* node type definition */
49{
50 namespace file_ns = nodes::node_shader_light_info_cc;
51
52 static bke::bNodeType ntype;
53
54 sh_node_type_base(&ntype, "ShaderNodeLightInfo"_ustr, SH_NODE_LIGHT_INFO);
55 ntype.ui_name = "Light Info";
56 ntype.ui_description =
57 "Exposes physical properties of the light being evaluated and computes basic information "
58 "relative to the evaluation position";
59 ntype.enum_name_legacy = "LIGHT_INFO";
61 ntype.declare = file_ns::node_declare;
63 ntype.gpu_fn = file_ns::node_shader_gpu_light_info;
64 // ntype.materialx_fn = file_ns::node_shader_materialx;
65
67}
68
69} // namespace blender
#define NODE_CLASS_INPUT
Definition BKE_node.hh:478
#define SH_NODE_LIGHT_INFO
#define BLI_assert_unreachable()
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static void node_declare(NodeDeclarationBuilder &b)
static int node_shader_gpu_light_info(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,...)
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
void register_node_type_sh_light_info()
@ NTREE_IS_GPU_SHADER_INTERNAL
GPUNodeLink * GPU_kernel_globals()
void search_link_ops_for_shader_material_lighting_node(nodes::GatherLinkSearchOpParams &params)
eNodeTree_Flag flag
Defines a node type.
Definition BKE_node.hh:265
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
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
Definition BKE_node.hh:409
NodeDeclareFunction declare
Definition BKE_node.hh:393