Blender V5.3
node_shader_light_accumulation.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 const bNodeTree *ntree = b.tree_or_null();
18 const bool is_gpu_internal = ntree && (ntree->flag & NTREE_IS_GPU_SHADER_INTERNAL);
19
20 b.add_input<decl::Int>("LightIndex"_ustr).available(is_gpu_internal);
21
22 /* WATCH: If you add more Color sockets, ensure `node_tree_update.cc`
23 * `shader_tree_tag_by_ancestor` and `shader_tree_link_error` are updated accordingly. */
24 b.add_input<decl::Color>("Diffuse Light"_ustr)
25 .default_value({0.0f, 0.0f, 0.0f, 1.0f})
26 .hide_value();
27 b.add_input<decl::Color>("Diffuse Color"_ustr)
28 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
29 .hide_value();
30 b.add_input<decl::Color>("Glossy Light"_ustr)
31 .default_value({0.0f, 0.0f, 0.0f, 1.0f})
32 .hide_value();
33 b.add_input<decl::Color>("Glossy Color"_ustr)
34 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
35 .hide_value();
36 b.add_input<decl::Color>("Transmission Light"_ustr)
37 .default_value({0.0f, 0.0f, 0.0f, 1.0f})
38 .hide_value();
39 b.add_input<decl::Color>("Transmission Color"_ustr)
40 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
41 .hide_value();
42 b.add_input<decl::Float>("Weight"_ustr).available(is_gpu_internal);
43 b.add_output<decl::Shader>("Shader"_ustr);
44}
45
47 bNode *node,
48 bNodeExecData * /*execdata*/,
51{
52 if (!in[0].link) {
53 /* Error: not linked to a light accumulation zone. */
55 return false;
56 }
57
59
60 return GPU_stack_link(
61 mat, node, "node_light_accumulation", in, out, GPU_kernel_globals(), GPU_shading_data());
62}
63
64} // namespace nodes::node_shader_light_accumulation_cc
65
66/* node type definition */
68{
70
71 static bke::bNodeType ntype;
72
73 sh_node_type_base(&ntype, "ShaderNodeLightAccumulation"_ustr, SH_NODE_LIGHT_ACCUMULATION);
74 ntype.ui_name = "Light Accumulation";
75 ntype.ui_description =
76 "Adds the result of all the evaluated lights and stores each input into its respective "
77 "Compositing Pass.\n"
78 "The combined result is computed as (Diffuse Light * Diffuse Color) + (Glossy Light * "
79 "Glossy Color)";
80 ntype.enum_name_legacy = "LIGHT_ACCUMULATION";
82 ntype.declare = file_ns::node_declare;
84 ntype.gpu_fn = file_ns::node_shader_gpu_light_accumulation;
85 // ntype.materialx_fn = file_ns::node_shader_materialx;
86
88}
89
90} // namespace blender
#define NODE_CLASS_SHADER
Definition BKE_node.hh:491
#define SH_NODE_LIGHT_ACCUMULATION
#define BLI_assert_unreachable()
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static int node_shader_gpu_light_accumulation(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_LIGHTING
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()
void register_node_type_sh_light_accumulation()
@ 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