Blender V4.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
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").default_value(1.0f).min(0.0f).max(1000000.0f);
13 b.add_input<decl::Float>("Weight").available(false);
14 b.add_output<decl::Shader>("Emission");
15}
16
18 bNode *node,
19 bNodeExecData * /*execdata*/,
20 GPUNodeStack *in,
21 GPUNodeStack *out)
22{
24 return GPU_stack_link(mat, node, "node_emission", in, out);
25}
26
28#ifdef WITH_MATERIALX
29{
30 if (to_type_ != NodeItem::Type::EDF) {
31 return empty();
32 }
33
34 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
35 NodeItem strength = get_input_value("Strength", NodeItem::Type::Float);
36
37 return create_node("uniform_edf", NodeItem::Type::EDF, {{"color", color * strength}});
38}
39#endif
41
42} // namespace blender::nodes::node_shader_emission_cc
43
44/* node type definition */
46{
48
49 static blender::bke::bNodeType ntype;
50
51 sh_node_type_base(&ntype, SH_NODE_EMISSION, "Emission", NODE_CLASS_SHADER);
52 ntype.declare = file_ns::node_declare;
53 ntype.gpu_fn = file_ns::node_shader_gpu_emission;
54 ntype.materialx_fn = file_ns::node_shader_materialx;
55
57}
#define NODE_CLASS_SHADER
Definition BKE_node.hh:417
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)
local_group_size(16, 16) .push_constant(Type b
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
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, int type, const char *name, short nclass)
Defines a node type.
Definition BKE_node.hh:218
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:320
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:318
NodeDeclareFunction declare
Definition BKE_node.hh:347