Blender V5.3
node_shader_emission.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 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::Color>("Color"_ustr).default_value({1.0f, 1.0f, 1.0f, 1.0f});
21 b.add_input<decl::Float>("Strength"_ustr)
22 .default_value(1.0f)
23 .min(0.0f)
24 .max(1000000.0f)
26 b.add_input<decl::Float>("Weight"_ustr).available(is_gpu_internal);
27 b.add_output<decl::Shader>("Emission"_ustr);
28}
29
31 bNode *node,
32 bNodeExecData * /*execdata*/,
35{
37 return GPU_stack_link(
38 mat, node, "node_emission", in, out, GPU_kernel_globals(), GPU_shading_data());
39}
40
42#ifdef WITH_MATERIALX
43{
44 if (to_type_ != NodeItem::Type::EDF) {
45 return empty();
46 }
47
48 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
49 NodeItem strength = get_input_value("Strength", NodeItem::Type::Float);
50
51 return create_node("uniform_edf", NodeItem::Type::EDF, {{"color", color * strength}});
52}
53#endif
55
56} // namespace nodes::node_shader_emission_cc
57
58/* node type definition */
60{
61 namespace file_ns = nodes::node_shader_emission_cc;
62
63 static bke::bNodeType ntype;
64
65 sh_node_type_base(&ntype, "ShaderNodeEmission"_ustr, SH_NODE_EMISSION);
66 ntype.ui_name = "Emission";
67 ntype.ui_description = "Lambertian emission shader";
68 ntype.enum_name_legacy = "EMISSION";
70 ntype.declare = file_ns::node_declare;
72 ntype.gpu_fn = file_ns::node_shader_gpu_emission;
73 ntype.materialx_fn = file_ns::node_shader_materialx;
74
76}
77
78} // namespace blender
#define NODE_CLASS_SHADER
Definition BKE_node.hh:491
#define SH_NODE_EMISSION
#define BLT_I18NCONTEXT_AMOUNT
std::optional< std::string > translation_context
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static void node_declare(NodeDeclarationBuilder &b)
static int node_shader_gpu_emission(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_EMISSION
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
void search_link_ops_for_shader_bsdf_node(nodes::GatherLinkSearchOpParams &params)
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
void register_node_type_sh_emission()
GPUNodeLink * GPU_shading_data()
@ NTREE_IS_GPU_SHADER_INTERNAL
GPUNodeLink * GPU_kernel_globals()
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
eNodeTree_Flag flag
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
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
Definition BKE_node.hh:409
NodeDeclareFunction declare
Definition BKE_node.hh:393