Blender V5.0
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
5#include "node_shader_util.hh"
6
8
10{
11 b.add_input<decl::Float>("Strength")
12 .default_value(100.0f)
13 .min(0.0f)
14 .max(1000000.0f)
15 .description("Light strength before applying falloff modification")
16 .translation_context(BLT_I18NCONTEXT_AMOUNT);
17
18 b.add_input<decl::Float>("Smooth").default_value(0.0f).min(0.0f).max(1000.0f).description(
19 "Smooth intensity of light near light sources.\n"
20 "This can avoid harsh highlights, and reduce global illumination noise. "
21 "0.0 corresponds to no smoothing; higher values smooth more");
22 b.add_output<decl::Float>("Quadratic");
23 b.add_output<decl::Float>("Linear");
24 b.add_output<decl::Float>("Constant");
25}
26
28 bNode *node,
29 bNodeExecData * /*execdata*/,
32{
33 return GPU_stack_link(mat, node, "node_light_falloff", in, out);
34}
35
37#ifdef WITH_MATERIALX
38{
39 NodeItem strength = get_input_value("Strength", NodeItem::Type::Float);
40 NodeItem smooth = get_input_value("Smooth", NodeItem::Type::Float);
41
42 /* This node isn't supported by MaterialX. This formula was given from OSL shader code in Cycles
43 * node_light_falloff.osl. Considered ray_length=1.0f. */
44 return strength / (smooth + val(1.0f));
45}
46#endif
48
49} // namespace blender::nodes::node_shader_light_falloff_cc
50
51/* node type definition */
53{
55
56 static blender::bke::bNodeType ntype;
57
58 sh_node_type_base(&ntype, "ShaderNodeLightFalloff", SH_NODE_LIGHT_FALLOFF);
59 ntype.ui_name = "Light Falloff";
60 ntype.ui_description =
61 "Manipulate how light intensity decreases over distance. Typically used for "
62 "non-physically-based effects; in reality light always falls off quadratically";
63 ntype.enum_name_legacy = "LIGHT_FALLOFF";
65 ntype.declare = file_ns::node_declare;
67 ntype.gpu_fn = file_ns::node_shader_gpu_light_falloff;
68 ntype.materialx_fn = file_ns::node_shader_materialx;
69
71}
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:449
#define SH_NODE_LIGHT_FALLOFF
#define BLT_I18NCONTEXT_AMOUNT
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
#define in
#define out
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
void node_type_size_preset(bNodeType &ntype, eNodeSizePreset size)
Definition node.cc:5396
static void node_declare(NodeDeclarationBuilder &b)
static int node_shader_gpu_light_falloff(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_light_falloff()
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