33 .description(
"Segment coordinates for texture mapping within each angular segment");
37 "Unique ID for every angular segment starting at 0 and increasing counterclockwise by "
42 "Relative width of each angular segment. "
43 "May be used to scale textures to fit into each segment");
47 "Counterclockwise rotation of each segment coordinates system. May be used to align the "
48 "rotation of the textures of each segment");
52 .default_value(
float3{0.0f, 0.0f, 0.0f})
53 .description(
"Input texture coordinates");
59 "Number of angular segments for tiling. A non-integer value results in an irregular "
66 .description(
"Roundness of the segment coordinates systems");
84 return "node_radial_tiling";
94 float normalize_r_gon_parameter =
storage.normalize;
95 float calculate_r_gon_parameter_field =
out[0].hasoutput;
96 float calculate_segment_id =
out[1].hasoutput;
97 float calculate_max_unit_parameter =
out[2].hasoutput;
98 float calculate_x_axis_A_angle_bisector =
out[3].hasoutput;
116 bool normalize_r_gon_parameter_;
118 mf::Signature signature_;
122 : normalize_r_gon_parameter_(normalize_r_gon_parameter)
131 mf::SignatureBuilder builder{
"radial_tiling",
signature};
133 builder.single_input<
float3>(
"Vector");
135 builder.single_input<
float>(
"Sides");
136 builder.single_input<
float>(
"Roundness");
138 builder.single_output<
float3>(
"Segment Coordinates", mf::ParamFlag::SupportsUnusedOutput);
139 builder.single_output<
float>(
"Segment ID", mf::ParamFlag::SupportsUnusedOutput);
140 builder.single_output<
float>(
"Segment Width", mf::ParamFlag::SupportsUnusedOutput);
141 builder.single_output<
float>(
"Segment Rotation", mf::ParamFlag::SupportsUnusedOutput);
152 const VArray<float> &r_gon_sides = params.readonly_single_input<
float>(param++,
"Sides");
153 const VArray<float> &r_gon_roundness = params.readonly_single_input<
float>(param++,
157 params.uninitialized_single_output_if_required<
float3>(param++,
"Segment Coordinates");
158 MutableSpan<float> r_segment_id = params.uninitialized_single_output_if_required<
float>(
159 param++,
"Segment ID");
161 params.uninitialized_single_output_if_required<
float>(param++,
"Segment Width");
163 params.uninitialized_single_output_if_required<
float>(param++,
"Segment Rotation");
165 const bool calculate_r_gon_parameter_field = !r_segment_coordinates.
is_empty();
166 const bool calculate_segment_id = !r_segment_id.is_empty();
167 const bool calculate_max_unit_parameter = !r_max_unit_parameter.is_empty();
168 const bool calculate_x_axis_A_angle_bisector = !r_x_axis_A_angle_bisector.is_empty();
171 if (calculate_r_gon_parameter_field || calculate_max_unit_parameter ||
172 calculate_x_axis_A_angle_bisector)
175 calculate_max_unit_parameter,
176 normalize_r_gon_parameter_,
181 if (calculate_r_gon_parameter_field) {
182 r_segment_coordinates[i] =
float3(out_variables.y, out_variables.x, 0.0f);
184 if (calculate_max_unit_parameter) {
185 r_max_unit_parameter[i] = out_variables.z;
187 if (calculate_x_axis_A_angle_bisector) {
188 r_x_axis_A_angle_bisector[i] = out_variables.w;
192 if (calculate_segment_id) {
201 static constexpr int8_t id = 0;
203 hash.add(normalize_r_gon_parameter_);
230 ntype.
ui_name =
"Radial Tiling";
231 ntype.
ui_description =
"Transform Coordinate System for Radial Tiling";
233 ntype.
declare = file_ns::sh_node_radial_tiling_declare;
234 ntype.
draw_buttons = file_ns::node_shader_buts_radial_tiling;
235 ntype.
initfunc = file_ns::node_shader_init_radial_tiling;
238 ntype.
gpu_fn = file_ns::node_shader_gpu_radial_tiling;
#define NODE_STORAGE_FUNCS(StorageT)
#define NODE_CLASS_OP_VECTOR
constexpr bool is_empty() const
const Signature & signature() const
void set_signature(const Signature *signature)
void construct_and_set_matching_fn(Args &&...args)
RoundedPolygonFunction(bool normalize_r_gon_parameter)
void call(const IndexMask &mask, mf::Params params, mf::Context) const override
ExecutionHints get_execution_hints() const override
static mf::Signature create_signature()
void hash_unique(UniqueHashBytes &hash) const override
#define storage(slot, qualifiers)
void node_register_type(bNodeType &ntype)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
T clamp(const T &a, const T &min, const T &max)
T max(const T &a, const T &b)
static void node_shader_init_radial_tiling(bNodeTree *, bNode *node)
static int node_shader_gpu_radial_tiling(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void sh_node_radial_tiling_build_multi_function(NodeMultiFunctionBuilder &builder)
static const char * gpu_shader_get_name()
static void node_shader_buts_radial_tiling(ui::Layout &layout, bContext *, PointerRNA *ptr)
static void sh_node_radial_tiling_declare(NodeDeclarationBuilder &b)
@ ITEM_R_SPLIT_EMPTY_NAME
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
VecBase< float, 4 > float4
GPUNodeLink * GPU_constant(const float *num)
VecBase< float, 2 > float2
float calculate_out_segment_id(float r_gon_sides, float2 coord)
void register_node_type_sh_radial_tiling()
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
void node_free_standard_storage(bNode *node)
VecBase< float, 3 > float3
float4 calculate_out_variables(bool calculate_r_gon_parameter_field, bool calculate_max_unit_parameter, bool normalize_r_gon_parameter, float r_gon_sides, float r_gon_roundness, float2 coord)
void common_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
std::string ui_description
NodeGPUExecFunction gpu_fn
NodeMultiFunctionBuildFunction build_multi_function
void(*) initfunc(bNodeTree *ntree, bNode *node)
NodeDeclareFunction declare
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)