Blender V5.0
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
5#include "node_shader_util.hh"
6
8
10{
11 b.add_input<decl::Color>("Color").default_value({1.0f, 1.0f, 1.0f, 1.0f});
12 b.add_input<decl::Float>("Strength")
13 .default_value(1.0f)
14 .min(0.0f)
15 .max(1000000.0f)
17 b.add_input<decl::Float>("Weight").available(false);
18 b.add_output<decl::Shader>("Emission");
19}
20
22 bNode *node,
23 bNodeExecData * /*execdata*/,
26{
28 return GPU_stack_link(mat, node, "node_emission", in, out);
29}
30
32#ifdef WITH_MATERIALX
33{
34 if (to_type_ != NodeItem::Type::EDF) {
35 return empty();
36 }
37
38 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
39 NodeItem strength = get_input_value("Strength", NodeItem::Type::Float);
40
41 return create_node("uniform_edf", NodeItem::Type::EDF, {{"color", color * strength}});
42}
43#endif
45
46} // namespace blender::nodes::node_shader_emission_cc
47
48/* node type definition */
50{
52
53 static blender::bke::bNodeType ntype;
54
55 sh_node_type_base(&ntype, "ShaderNodeEmission", SH_NODE_EMISSION);
56 ntype.ui_name = "Emission";
57 ntype.ui_description = "Lambertian emission shader";
58 ntype.enum_name_legacy = "EMISSION";
60 ntype.declare = file_ns::node_declare;
61 ntype.gpu_fn = file_ns::node_shader_gpu_emission;
62 ntype.materialx_fn = file_ns::node_shader_materialx;
63
65}
#define NODE_CLASS_SHADER
Definition BKE_node.hh:460
#define SH_NODE_EMISSION
#define BLT_I18NCONTEXT_AMOUNT
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
@ GPU_MATFLAG_EMISSION
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
std::optional< std::string > translation_context
#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_emission(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_emission()
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