Blender  V3.3
node_shader_wavelength.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2005 Blender Foundation. All rights reserved. */
3 
4 #include "node_shader_util.hh"
5 
6 #include "IMB_colormanagement.h"
7 
9 
11 {
12  b.add_input<decl::Float>(N_("Wavelength")).default_value(500.0f).min(380.0f).max(780.0f);
13  b.add_output<decl::Color>(N_("Color"));
14 }
15 
17  bNode *node,
18  bNodeExecData *UNUSED(execdata),
19  GPUNodeStack *in,
21 {
22  const int size = CM_TABLE + 1;
23  float *data = static_cast<float *>(MEM_mallocN(sizeof(float) * size * 4, "cie_xyz texture"));
24 
26 
27  float layer;
28  GPUNodeLink *ramp_texture = GPU_color_band(mat, size, data, &layer);
29  return GPU_stack_link(mat, node, "node_wavelength", in, out, ramp_texture, GPU_constant(&layer));
30 }
31 
32 } // namespace blender::nodes::node_shader_wavelength_cc
33 
34 /* node type definition */
36 {
38 
39  static bNodeType ntype;
40 
45 
46  nodeRegisterType(&ntype);
47 }
void node_type_gpu(struct bNodeType *ntype, NodeGPUExecFunction gpu_fn)
Definition: node.cc:4465
#define NODE_CLASS_CONVERTER
Definition: BKE_node.h:351
void node_type_size_preset(struct bNodeType *ntype, eNodeSizePreset size)
Definition: node.cc:4408
#define SH_NODE_WAVELENGTH
Definition: BKE_node.h:1151
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
@ NODE_SIZE_MIDDLE
Definition: BKE_node.h:366
#define UNUSED(x)
#define CM_TABLE
GPUNodeLink * GPU_color_band(GPUMaterial *mat, int size, float *pixels, float *row)
GPUNodeLink * GPU_constant(const float *num)
bool GPU_stack_link(GPUMaterial *mat, struct bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
void IMB_colormanagement_wavelength_to_rgb_table(float *r_table, int width)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
OperationNode * node
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
static void node_declare(NodeDeclarationBuilder &b)
static int node_shader_gpu_wavelength(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass)
void register_node_type_sh_wavelength()
Defines a node type.
Definition: BKE_node.h:226
NodeDeclareFunction declare
Definition: BKE_node.h:324
#define N_(msgid)