Blender V4.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
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*/,
24 GPUNodeStack *in,
25 GPUNodeStack *out)
26{
27 const int size = CM_TABLE + 1;
28 float *data = static_cast<float *>(MEM_mallocN(sizeof(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
47 ntype.declare = file_ns::node_declare;
49 ntype.gpu_fn = file_ns::node_shader_gpu_wavelength;
50
52}
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:410
#define SH_NODE_WAVELENGTH
Definition BKE_node.hh:963
#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:190
local_group_size(16, 16) .push_constant(Type b
void *(* MEM_mallocN)(size_t len, const char *str)
Definition mallocn.cc:44
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_wavelength(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
void sh_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
void register_node_type_sh_wavelength()
Defines a node type.
Definition BKE_node.hh:218
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:318
NodeDeclareFunction declare
Definition BKE_node.hh:347