41 static const mf::Signature
signature = []() {
43 mf::SignatureBuilder builder{
"Separate XYZ",
signature};
44 builder.single_input<
float3>(
"XYZ");
45 builder.single_output<
float>(
"X", mf::ParamFlag::SupportsUnusedOutput);
46 builder.single_output<
float>(
"Y", mf::ParamFlag::SupportsUnusedOutput);
47 builder.single_output<
float>(
"Z", mf::ParamFlag::SupportsUnusedOutput);
60 std::array<MutableSpan<float>, 3>
outputs = {xs, ys, zs};
73 mask.foreach_segment_optimized([&](
const auto segment) {
74 const int used_outputs_num = used_outputs.
size();
75 const int *used_outputs_data = used_outputs.
data();
79 for (
const int out_i :
IndexRange(used_outputs_num)) {
80 const int coordinate = used_outputs_data[out_i];
98 const VectorElem vector_elem =
params.get_input_elem<VectorElem>(
"Vector");
99 params.set_output_elem(
"X", vector_elem.x);
100 params.set_output_elem(
"Y", vector_elem.y);
101 params.set_output_elem(
"Z", vector_elem.z);
116 params.set_input(
"Vector",
118 params.get_output<
float>(
"Y"),
119 params.get_output<
float>(
"Z")));
125 NodeItem
vector = get_input_value(
"Vector", NodeItem::Type::Vector3);
126 int index =
STREQ(socket_out_->identifier,
"X") ? 0 :
127 STREQ(socket_out_->identifier,
"Y") ? 1 :
143 ntype.
ui_name =
"Separate XYZ";
144 ntype.
ui_description =
"Split a vector into its X, Y, and Z components";
147 ntype.
declare = file_ns::sh_node_sepxyz_declare;
148 ntype.
gpu_fn = file_ns::gpu_shader_sepxyz;
151 ntype.
eval_elem = file_ns::sh_node_sepxyz_eval_elem;
153 ntype.
eval_inverse = file_ns::sh_node_sepxyz_eval_inverse;
162 b.is_function_node();
180 static auto fn = mf::build::SI3_SO<float, float, float, float3>(
182 [](
float x,
float y,
float z) {
return float3(
x,
y,
z); },
183 mf::build::exec_presets::AllSpanOrSingle());
190 VectorElem vector_elem;
191 vector_elem.x =
params.get_input_elem<FloatElem>(
"X");
192 vector_elem.y =
params.get_input_elem<FloatElem>(
"Y");
193 vector_elem.z =
params.get_input_elem<FloatElem>(
"Z");
194 params.set_output_elem(
"Vector", vector_elem);
200 const VectorElem output_elem =
params.get_output_elem<VectorElem>(
"Vector");
201 params.set_input_elem(
"X", output_elem.x);
202 params.set_input_elem(
"Y", output_elem.y);
203 params.set_input_elem(
"Z", output_elem.z);
217 NodeItem
x = get_input_value(
"X", NodeItem::Type::Float);
218 NodeItem
y = get_input_value(
"Y", NodeItem::Type::Float);
219 NodeItem
z = get_input_value(
"Z", NodeItem::Type::Float);
221 return create_node(
"combine3", NodeItem::Type::Vector3, {{
"in1",
x}, {
"in2",
y}, {
"in3",
z}});
236 ntype.
ui_description =
"Create a vector from X, Y, and Z components";
239 ntype.
declare = file_ns::sh_node_combxyz_declare;
240 ntype.
gpu_fn = file_ns::gpu_shader_combxyz;
243 ntype.
eval_elem = file_ns::sh_node_combxyz_eval_elem;
245 ntype.
eval_inverse = file_ns::sh_node_combxyz_eval_inverse;
#define NODE_CLASS_CONVERTER
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
void append(const T &value)
const Signature & signature() const
void set_signature(const Signature *signature)
void set_matching_fn(const mf::MultiFunction *fn)
void call(const IndexMask &mask, mf::Params params, mf::Context) const override
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
void node_register_type(bNodeType &ntype)
static int gpu_shader_combxyz(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void sh_node_combxyz_eval_inverse_elem(value_elem::InverseElemEvalParams ¶ms)
static void sh_node_combxyz_eval_elem(value_elem::ElemEvalParams ¶ms)
static void sh_node_combxyz_eval_inverse(inverse_eval::InverseEvalParams ¶ms)
static void sh_node_combxyz_build_multi_function(NodeMultiFunctionBuilder &builder)
static void sh_node_combxyz_declare(NodeDeclarationBuilder &b)
static void sh_node_sepxyz_build_multi_function(NodeMultiFunctionBuilder &builder)
static void sh_node_sepxyz_eval_inverse_elem(value_elem::InverseElemEvalParams ¶ms)
static int gpu_shader_sepxyz(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void sh_node_sepxyz_eval_elem(value_elem::ElemEvalParams ¶ms)
static void sh_node_sepxyz_declare(NodeDeclarationBuilder &b)
static void sh_node_sepxyz_eval_inverse(inverse_eval::InverseEvalParams ¶ms)
void devirtualize_varray(const VArray< T > &varray, const Func &func, bool enable=true)
VecBase< float, 3 > float3
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_combxyz()
void register_node_type_sh_sepxyz()
void common_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
static blender::bke::bNodeSocketTemplate outputs[]
NodeInverseElemEvalFunction eval_inverse_elem
NodeMaterialXFunction materialx_fn
NodeInverseEvalFunction eval_inverse
std::string ui_description
NodeGPUExecFunction gpu_fn
NodeElemEvalFunction eval_elem
NodeMultiFunctionBuildFunction build_multi_function
const char * enum_name_legacy
NodeDeclareFunction declare