Blender V4.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
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
17 b.add_input<decl::Float>("Smooth").default_value(0.0f).min(0.0f).max(1000.0f).description(
18 "Smooth intensity of light near light sources.\n"
19 "This can avoid harsh highlights, and reduce global illumination noise. "
20 "0.0 corresponds to no smoothing; higher values smooth more");
21 b.add_output<decl::Float>("Quadratic");
22 b.add_output<decl::Float>("Linear");
23 b.add_output<decl::Float>("Constant");
24}
25
27 bNode *node,
28 bNodeExecData * /*execdata*/,
29 GPUNodeStack *in,
30 GPUNodeStack *out)
31{
32 return GPU_stack_link(mat, node, "node_light_falloff", in, out);
33}
34
36#ifdef WITH_MATERIALX
37{
38 NodeItem strength = get_input_value("Strength", NodeItem::Type::Float);
39 NodeItem smooth = get_input_value("Smooth", NodeItem::Type::Float);
40
41 /* This node isn't supported by MaterialX. This formula was given from OSL shader code in Cycles
42 * node_light_falloff.osl. Considered ray_length=1.0f. */
43 return strength / (smooth + val(1.0f));
44}
45#endif
47
48} // namespace blender::nodes::node_shader_light_falloff_cc
49
50/* node type definition */
52{
54
55 static blender::bke::bNodeType ntype;
56
57 sh_node_type_base(&ntype, SH_NODE_LIGHT_FALLOFF, "Light Falloff", NODE_CLASS_OP_COLOR);
58 ntype.declare = file_ns::node_declare;
60 ntype.gpu_fn = file_ns::node_shader_gpu_light_falloff;
61 ntype.materialx_fn = file_ns::node_shader_materialx;
62
64}
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:406
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
local_group_size(16, 16) .push_constant(Type b
void node_type_size_preset(bNodeType *ntype, eNodeSizePreset size)
Definition node.cc:4614
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
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, 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