Blender V5.0
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
5#include "node_shader_util.hh"
6
8
10
12{
13 b.add_input<decl::Float>("Wavelength")
14 .default_value(500.0f)
15 .min(380.0f)
16 .max(780.0f)
18 b.add_output<decl::Color>("Color");
19}
20
22 bNode *node,
23 bNodeExecData * /*execdata*/,
26{
27 const int size = CM_TABLE + 1;
28 float *data = MEM_malloc_arrayN<float>(size * 4, "cie_xyz texture");
29
31
32 float layer;
33 GPUNodeLink *ramp_texture = GPU_color_band(mat, size, data, &layer);
34 return GPU_stack_link(mat, node, "node_wavelength", in, out, ramp_texture, GPU_constant(&layer));
35}
36
37} // namespace blender::nodes::node_shader_wavelength_cc
38
39/* node type definition */
41{
43
44 static blender::bke::bNodeType ntype;
45
46 sh_node_type_base(&ntype, "ShaderNodeWavelength", SH_NODE_WAVELENGTH);
47 ntype.ui_name = "Wavelength";
48 ntype.ui_description = "Convert a wavelength value to an RGB value";
49 ntype.enum_name_legacy = "WAVELENGTH";
51 ntype.declare = file_ns::node_declare;
53 ntype.gpu_fn = file_ns::node_shader_gpu_wavelength;
54
56}
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:453
#define SH_NODE_WAVELENGTH
#define CM_TABLE
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
GPUNodeLink * GPU_constant(const float *num)
GPUNodeLink * GPU_color_band(GPUMaterial *mat, int size, float *pixels, float *r_row)
void IMB_colormanagement_wavelength_to_rgb_table(float *r_table, int width)
@ PROP_WAVELENGTH
Definition RNA_types.hh:287
BMesh const char void * data
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
#define in
#define out
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
Definition mallocn.cc:133
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_wavelength(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
void sh_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
void register_node_type_sh_wavelength()
Defines a node type.
Definition BKE_node.hh:238
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