Blender V5.3
node_shader_light_falloff.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 b.add_input<decl::Float>("Strength"_ustr)
18 .default_value(100.0f)
19 .min(0.0f)
20 .max(1000000.0f)
21 .description("Light strength before applying falloff modification")
22 .translation_context(BLT_I18NCONTEXT_AMOUNT);
23
24 b.add_input<decl::Float>("Smooth"_ustr)
25 .default_value(0.0f)
26 .min(0.0f)
27 .max(1000.0f)
29 "Smooth intensity of light near light sources.\n"
30 "This can avoid harsh highlights, and reduce global illumination noise. "
31 "0.0 corresponds to no smoothing; higher values smooth more");
32 b.add_output<decl::Float>("Quadratic"_ustr);
33 b.add_output<decl::Float>("Linear"_ustr);
34 b.add_output<decl::Float>("Constant"_ustr);
35}
36
38 bNode *node,
39 bNodeExecData * /*execdata*/,
42{
43 return GPU_stack_link(mat, node, "node_light_falloff", in, out);
44}
45
47#ifdef WITH_MATERIALX
48{
49 NodeItem strength = get_input_value("Strength", NodeItem::Type::Float);
50 NodeItem smooth = get_input_value("Smooth", NodeItem::Type::Float);
51
52 /* This node isn't supported by MaterialX. This formula was given from OSL shader code in Cycles
53 * node_light_falloff.osl. Considered ray_length=1.0f. */
54 return strength / (smooth + val(1.0f));
55}
56#endif
58
59} // namespace nodes::node_shader_light_falloff_cc
60
61/* node type definition */
63{
64 namespace file_ns = nodes::node_shader_light_falloff_cc;
65
66 static bke::bNodeType ntype;
67
68 sh_node_type_base(&ntype, "ShaderNodeLightFalloff"_ustr, SH_NODE_LIGHT_FALLOFF);
69 ntype.ui_name = "Light Falloff";
70 ntype.ui_description =
71 "Manipulate how light intensity decreases over distance. Typically used for "
72 "non-physically-based effects; in reality light always falls off quadratically";
73 ntype.enum_name_legacy = "LIGHT_FALLOFF";
75 ntype.declare = file_ns::node_declare;
77 ntype.gpu_fn = file_ns::node_shader_gpu_light_falloff;
78 ntype.materialx_fn = file_ns::node_shader_materialx;
79
81}
82
83} // namespace blender
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:480
#define SH_NODE_LIGHT_FALLOFF
#define BLT_I18NCONTEXT_AMOUNT
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static void node_declare(NodeDeclarationBuilder &b)
static int node_shader_gpu_light_falloff(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_falloff()
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
static constexpr int _160
Definition BKE_node.hh:246
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
NodeDeclareFunction declare
Definition BKE_node.hh:393