Blender  V3.3
node_shader_sepcomb_xyz.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2014 Blender Foundation. All rights reserved. */
3 
8 #include "node_shader_util.hh"
9 
11 
13 {
14  b.is_function_node();
15  b.add_input<decl::Vector>(N_("Vector")).min(-10000.0f).max(10000.0f);
16  b.add_output<decl::Float>(N_("X"));
17  b.add_output<decl::Float>(N_("Y"));
18  b.add_output<decl::Float>(N_("Z"));
19 }
20 
22  bNode *node,
23  bNodeExecData *UNUSED(execdata),
24  GPUNodeStack *in,
26 {
27  return GPU_stack_link(mat, node, "separate_xyz", in, out);
28 }
29 
31  public:
33  {
35  this->set_signature(&signature);
36  }
37 
39  {
40  fn::MFSignatureBuilder signature{"Separate XYZ"};
41  signature.single_input<float3>("XYZ");
42  signature.single_output<float>("X");
43  signature.single_output<float>("Y");
44  signature.single_output<float>("Z");
45  return signature.build();
46  }
47 
49  {
50  const VArray<float3> &vectors = params.readonly_single_input<float3>(0, "XYZ");
51  MutableSpan<float> xs = params.uninitialized_single_output_if_required<float>(1, "X");
52  MutableSpan<float> ys = params.uninitialized_single_output_if_required<float>(2, "Y");
53  MutableSpan<float> zs = params.uninitialized_single_output_if_required<float>(3, "Z");
54 
55  std::array<MutableSpan<float>, 3> outputs = {xs, ys, zs};
56  Vector<int> used_outputs;
57  if (!xs.is_empty()) {
58  used_outputs.append(0);
59  }
60  if (!ys.is_empty()) {
61  used_outputs.append(1);
62  }
63  if (!zs.is_empty()) {
64  used_outputs.append(2);
65  }
66 
67  devirtualize_varray(vectors, [&](auto vectors) {
68  mask.to_best_mask_type([&](auto mask) {
69  const int used_outputs_num = used_outputs.size();
70  const int *used_outputs_data = used_outputs.data();
71 
72  for (const int64_t i : mask) {
73  const float3 &vector = vectors[i];
74  for (const int out_i : IndexRange(used_outputs_num)) {
75  const int coordinate = used_outputs_data[out_i];
76  outputs[coordinate][i] = vector[coordinate];
77  }
78  }
79  });
80  });
81  }
82 };
83 
85 {
86  static MF_SeparateXYZ separate_fn;
87  builder.set_matching_fn(separate_fn);
88 }
89 
90 } // namespace blender::nodes::node_shader_sepcomb_xyz_cc
91 
93 {
95 
96  static bNodeType ntype;
97 
102 
103  nodeRegisterType(&ntype);
104 }
105 
107 
109 {
110  b.is_function_node();
111  b.add_input<decl::Float>(N_("X")).min(-10000.0f).max(10000.0f);
112  b.add_input<decl::Float>(N_("Y")).min(-10000.0f).max(10000.0f);
113  b.add_input<decl::Float>(N_("Z")).min(-10000.0f).max(10000.0f);
114  b.add_output<decl::Vector>(N_("Vector"));
115 }
116 
118  bNode *node,
119  bNodeExecData *UNUSED(execdata),
120  GPUNodeStack *in,
121  GPUNodeStack *out)
122 {
123  return GPU_stack_link(mat, node, "combine_xyz", in, out);
124 }
125 
127 {
129  "Combine Vector",
130  [](float x, float y, float z) { return float3(x, y, z); },
132  builder.set_matching_fn(fn);
133 }
134 
135 } // namespace blender::nodes::node_shader_sepcomb_xyz_cc
136 
138 {
139  namespace file_ns = blender::nodes::node_shader_sepcomb_xyz_cc;
140 
141  static bNodeType ntype;
142 
147 
148  nodeRegisterType(&ntype);
149 }
void node_type_gpu(struct bNodeType *ntype, NodeGPUExecFunction gpu_fn)
Definition: node.cc:4465
#define SH_NODE_COMBXYZ
Definition: BKE_node.h:1160
#define NODE_CLASS_CONVERTER
Definition: BKE_node.h:351
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
#define UNUSED(x)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
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 SH_NODE_SEPXYZ
int64_t size() const
Definition: BLI_vector.hh:694
void append(const T &value)
Definition: BLI_vector.hh:433
void set_signature(const MFSignature *signature)
const MFSignature & signature() const
void set_matching_fn(const MultiFunction *fn)
void call(IndexMask mask, fn::MFParams params, fn::MFContext UNUSED(context)) const override
OperationNode * node
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
static int gpu_shader_combxyz(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
static void sh_node_combxyz_declare(NodeDeclarationBuilder &b)
static void sh_node_sepxyz_declare(NodeDeclarationBuilder &b)
static void sh_node_sepxyz_build_multi_function(NodeMultiFunctionBuilder &builder)
static void sh_node_combxyz_build_multi_function(NodeMultiFunctionBuilder &builder)
static int gpu_shader_sepxyz(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
void devirtualize_varray(const VArray< T > &varray, const Func &func, bool enable=true)
vec_base< float, 3 > float3
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void register_node_type_sh_combxyz()
void register_node_type_sh_sepxyz()
void sh_fn_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
static bNodeSocketTemplate outputs[]
#define min(a, b)
Definition: sort.c:35
__int64 int64_t
Definition: stdint.h:89
Defines a node type.
Definition: BKE_node.h:226
NodeMultiFunctionBuildFunction build_multi_function
Definition: BKE_node.h:313
NodeDeclareFunction declare
Definition: BKE_node.h:324
#define N_(msgid)