Blender V5.3
node_shader_wavelength.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
12
13namespace blender {
14
16
18{
19 b.add_input<decl::Float>("Wavelength"_ustr)
20 .default_value(500.0f)
21 .min(380.0f)
22 .max(780.0f)
24 b.add_output<decl::Color>("Color"_ustr);
25}
26
28 bNode *node,
29 bNodeExecData * /*execdata*/,
32{
33 const int size = CM_TABLE + 1;
34 float *data = MEM_new_array_uninitialized<float>(size * 4, "cie_xyz texture");
35
37
38 float layer;
39 GPUNodeLink *ramp_texture = GPU_color_band(mat, size, data, &layer);
40 return GPU_stack_link(mat, node, "node_wavelength", in, out, ramp_texture, GPU_constant(&layer));
41}
42
43} // namespace nodes::node_shader_wavelength_cc
44
45/* node type definition */
47{
48 namespace file_ns = nodes::node_shader_wavelength_cc;
49
50 static bke::bNodeType ntype;
51
52 sh_node_type_base(&ntype, "ShaderNodeWavelength"_ustr, SH_NODE_WAVELENGTH);
53 ntype.ui_name = "Wavelength";
54 ntype.ui_description = "Convert a wavelength value to an RGB value";
55 ntype.enum_name_legacy = "WAVELENGTH";
57 ntype.declare = file_ns::node_declare;
59 ntype.gpu_fn = file_ns::node_shader_gpu_wavelength;
60
62}
63
64} // namespace blender
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:484
#define SH_NODE_WAVELENGTH
#define CM_TABLE
#define layer
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static void node_declare(NodeDeclarationBuilder &b)
static int node_shader_gpu_wavelength(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 * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
GPUNodeLink * GPU_color_band(GPUMaterial *mat, int size, float *pixels, float *r_row)
void register_node_type_sh_wavelength()
GPUNodeLink * GPU_constant(const float *num)
BMesh const char void * data
void IMB_colormanagement_wavelength_to_rgb_table(float *r_table, int width)
@ PROP_WAVELENGTH
Definition RNA_types.hh:344
static constexpr int _160
Definition BKE_node.hh:246
Defines a node type.
Definition BKE_node.hh:265
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