43 static const mf::Signature
signature = []() {
45 mf::SignatureBuilder builder{
"Separate XYZ",
signature};
46 builder.single_input<
float3>(
"XYZ");
47 builder.single_output<
float>(
"X", mf::ParamFlag::SupportsUnusedOutput);
48 builder.single_output<
float>(
"Y", mf::ParamFlag::SupportsUnusedOutput);
49 builder.single_output<
float>(
"Z", mf::ParamFlag::SupportsUnusedOutput);
62 std::array<MutableSpan<float>, 3> outputs = {xs, ys, zs};
75 mask.foreach_segment_optimized([&](
const auto segment) {
76 const int used_outputs_num = used_outputs.
size();
77 const int *used_outputs_data = used_outputs.
data();
79 for (
const int64_t i : segment) {
80 const float3 &vector = vectors[i];
81 for (
const int out_i :
IndexRange(used_outputs_num)) {
82 const int coordinate = used_outputs_data[out_i];
83 outputs[coordinate][i] = vector[coordinate];
100 const VectorElem vector_elem = params.
get_input_elem<VectorElem>(
"Vector"_ustr);
127 NodeItem vector = get_input_value(
"Vector", NodeItem::Type::Vector3);
128 int index =
STREQ(socket_out_->identifier,
"X") ? 0 :
129 STREQ(socket_out_->identifier,
"Y") ? 1 :
131 return vector[
index];
145 ntype.
ui_name =
"Separate XYZ";
146 ntype.
ui_description =
"Split a vector into its X, Y, and Z components";
149 ntype.
declare = file_ns::sh_node_sepxyz_declare;
150 ntype.
gpu_fn = file_ns::gpu_shader_sepxyz;
153 ntype.
eval_elem = file_ns::sh_node_sepxyz_eval_elem;
155 ntype.
eval_inverse = file_ns::sh_node_sepxyz_eval_inverse;
164 b.is_function_node();
182 static auto fn = mf::build::SI3_SO<float, float, float, float3>(
184 [](
float x,
float y,
float z) {
return float3(
x,
y,
z); },
185 mf::build::exec_presets::AllSpanOrSingle());
192 VectorElem vector_elem;
202 const VectorElem output_elem = params.
get_output_elem<VectorElem>(
"Vector"_ustr);
219 NodeItem
x = get_input_value(
"X", NodeItem::Type::Float);
220 NodeItem
y = get_input_value(
"Y", NodeItem::Type::Float);
221 NodeItem
z = get_input_value(
"Z", NodeItem::Type::Float);
223 return create_node(
"combine3", NodeItem::Type::Vector3, {{
"in1",
x}, {
"in2",
y}, {
"in3",
z}});
238 ntype.
ui_description =
"Create a vector from X, Y, and Z components";
241 ntype.
declare = file_ns::sh_node_combxyz_declare;
242 ntype.
gpu_fn = file_ns::gpu_shader_combxyz;
245 ntype.
eval_elem = file_ns::sh_node_combxyz_eval_elem;
247 ntype.
eval_inverse = file_ns::sh_node_combxyz_eval_inverse;
#define NODE_CLASS_CONVERTER
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
constexpr IndexRange()=default
void append(const T &value)
const Signature & signature() const
void set_signature(const Signature *signature)
void set_matching_fn(const mf::MultiFunction *fn)
T get_output(const UString identifier) const
void set_input(const UString identifier, T value)
void call(const IndexMask &mask, mf::Params params, mf::Context) const override
T get_input_elem(const UString identifier) const
void set_output_elem(const UString identifier, T elem)
T get_output_elem(const UString identifier) const
void set_input_elem(const UString identifier, T elem)
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)
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
void devirtualize_varray(const VArray< T > &varray, const Func &func, bool enable=true)
void register_node_type_sh_sepxyz()
void register_node_type_sh_combxyz()
VecBase< float, 3 > float3
void common_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
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