Blender  V3.3
node_shader_sepcomb_color.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2022 Blender Foundation. All rights reserved. */
3 
8 #include "node_shader_util.hh"
9 
10 #include "UI_interface.h"
11 #include "UI_resources.h"
12 
14 {
15  NodeCombSepColor *data = MEM_cnew<NodeCombSepColor>(__func__);
17  node->storage = data;
18 }
19 
20 /* **************** SEPARATE COLOR ******************** */
21 
23 
25 
27 {
28  b.add_input<decl::Color>(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f});
29  b.add_output<decl::Float>(N_("Red"));
30  b.add_output<decl::Float>(N_("Green"));
31  b.add_output<decl::Float>(N_("Blue"));
32 }
33 
35 {
36  const NodeCombSepColor &storage = node_storage(*node);
38 }
39 
40 static const char *gpu_shader_get_name(int mode)
41 {
42  switch (mode) {
44  return "separate_color_rgb";
46  return "separate_color_hsv";
48  return "separate_color_hsl";
49  }
50 
51  return nullptr;
52 }
53 
55  bNode *node,
56  bNodeExecData *UNUSED(execdata),
57  GPUNodeStack *in,
59 {
60  const NodeCombSepColor &storage = node_storage(*node);
61  const char *name = gpu_shader_get_name(storage.mode);
62  if (name != nullptr) {
63  return GPU_stack_link(mat, node, name, in, out);
64  }
65 
66  return 0;
67 }
68 
69 } // namespace blender::nodes::node_shader_separate_color_cc
70 
72 {
74 
75  static bNodeType ntype;
76 
82  &ntype, "NodeCombSepColor", node_free_standard_storage, node_copy_standard_storage);
84 
85  nodeRegisterType(&ntype);
86 }
87 
88 /* **************** COMBINE COLOR ******************** */
89 
91 
93 
95 {
96  b.add_input<decl::Float>(N_("Red")).default_value(0.0f).min(0.0f).max(1.0f).subtype(PROP_FACTOR);
97  b.add_input<decl::Float>(N_("Green"))
98  .default_value(0.0f)
99  .min(0.0f)
100  .max(1.0f)
101  .subtype(PROP_FACTOR);
102  b.add_input<decl::Float>(N_("Blue"))
103  .default_value(0.0f)
104  .min(0.0f)
105  .max(1.0f)
106  .subtype(PROP_FACTOR);
107  b.add_output<decl::Color>(N_("Color"));
108 }
109 
111 {
112  const NodeCombSepColor &storage = node_storage(*node);
114 }
115 
116 static const char *gpu_shader_get_name(int mode)
117 {
118  switch (mode) {
120  return "combine_color_rgb";
122  return "combine_color_hsv";
124  return "combine_color_hsl";
125  }
126 
127  return nullptr;
128 }
129 
131  bNode *node,
132  bNodeExecData *UNUSED(execdata),
133  GPUNodeStack *in,
134  GPUNodeStack *out)
135 {
136  const NodeCombSepColor &storage = node_storage(*node);
137  const char *name = gpu_shader_get_name(storage.mode);
138  if (name != nullptr) {
139  return GPU_stack_link(mat, node, name, in, out);
140  }
141 
142  return 0;
143 }
144 
145 } // namespace blender::nodes::node_shader_combine_color_cc
146 
148 {
150 
151  static bNodeType ntype;
152 
158  &ntype, "NodeCombSepColor", node_free_standard_storage, node_copy_standard_storage);
160 
161  nodeRegisterType(&ntype);
162 }
void node_type_gpu(struct bNodeType *ntype, NodeGPUExecFunction gpu_fn)
Definition: node.cc:4465
#define SH_NODE_COMBINE_COLOR
Definition: BKE_node.h:1182
void node_type_update(struct bNodeType *ntype, void(*updatefunc)(struct bNodeTree *ntree, struct bNode *node))
Definition: node.cc:4443
#define NODE_CLASS_CONVERTER
Definition: BKE_node.h:351
#define NODE_STORAGE_FUNCS(StorageT)
Definition: BKE_node.h:1563
void node_type_init(struct bNodeType *ntype, void(*initfunc)(struct bNodeTree *ntree, struct bNode *node))
Definition: node.cc:4390
void node_type_storage(struct bNodeType *ntype, const char *storagename, void(*freefunc)(struct bNode *node), void(*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, const struct bNode *src_node))
Definition: node.cc:4426
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
#define UNUSED(x)
NodeCombSepColorMode
@ NODE_COMBSEP_COLOR_RGB
@ NODE_COMBSEP_COLOR_HSV
@ NODE_COMBSEP_COLOR_HSL
bool GPU_stack_link(GPUMaterial *mat, struct bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between and object coordinate space Combine Create a color from its and value channels Color Retrieve a color or the default fallback if none is specified Separate Split a vector into its and Z components Generates normals with round corners and may slow down renders Vector Displace the surface along an arbitrary direction White Return a random value or color based on an input seed Float Map an input float to a curve and outputs a float value SH_NODE_SEPARATE_COLOR
@ PROP_FACTOR
Definition: RNA_types.h:144
OperationNode * node
void * tree
bNodeTree * ntree
static void sh_node_combcolor_declare(NodeDeclarationBuilder &b)
static void node_combcolor_update(bNodeTree *UNUSED(ntree), bNode *node)
static int gpu_shader_combcolor(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
static void node_sepcolor_update(bNodeTree *UNUSED(ntree), bNode *node)
static int gpu_shader_sepcolor(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
static void sh_node_sepcolor_declare(NodeDeclarationBuilder &b)
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void register_node_type_sh_sepcolor()
void register_node_type_sh_combcolor()
static void node_combsep_color_init(bNodeTree *UNUSED(tree), bNode *node)
void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass)
void node_copy_standard_storage(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, const bNode *src_node)
Definition: node_util.c:55
void node_free_standard_storage(bNode *node)
Definition: node_util.c:43
void node_combsep_color_label(const ListBase *sockets, NodeCombSepColorMode mode)
Definition: node_util.c:229
Defines a node type.
Definition: BKE_node.h:226
NodeDeclareFunction declare
Definition: BKE_node.h:324
#define N_(msgid)