27 .description(
"Segment coordinates for texture mapping within each angular segment");
31 "Unique ID for every angular segment starting at 0 and increasing counterclockwise by "
36 "Relative width of each angular segment. "
37 "May be used to scale textures to fit into each segment");
41 "Counterclockwise rotation of each segment coordinates system. May be used to align the "
42 "rotation of the textures of each segment");
46 .default_value(
float3{0.0f, 0.0f, 0.0f})
47 .description(
"Input texture coordinates");
48 b.add_input<
decl::Float>(
"Sides").min(2.0f).
max(1000.0f).default_value(5.0f).description(
49 "Number of angular segments for tiling. A non-integer value results in an irregular "
56 .description(
"Roundness of the segment coordinates systems");
74 return "node_radial_tiling";
84 float normalize_r_gon_parameter = storage.
normalize;
85 float calculate_r_gon_parameter_field =
out[0].hasoutput;
86 float calculate_segment_id =
out[1].hasoutput;
87 float calculate_max_unit_parameter =
out[2].hasoutput;
88 float calculate_x_axis_A_angle_bisector =
out[3].hasoutput;
106 bool normalize_r_gon_parameter_;
108 mf::Signature signature_;
112 : normalize_r_gon_parameter_(normalize_r_gon_parameter)
121 mf::SignatureBuilder builder{
"radial_tiling",
signature};
123 builder.single_input<
float3>(
"Vector");
125 builder.single_input<
float>(
"Sides");
126 builder.single_input<
float>(
"Roundness");
128 builder.single_output<
float3>(
"Segment Coordinates", mf::ParamFlag::SupportsUnusedOutput);
129 builder.single_output<
float>(
"Segment ID", mf::ParamFlag::SupportsUnusedOutput);
130 builder.single_output<
float>(
"Segment Width", mf::ParamFlag::SupportsUnusedOutput);
131 builder.single_output<
float>(
"Segment Rotation", mf::ParamFlag::SupportsUnusedOutput);
147 params.uninitialized_single_output_if_required<
float3>(param++,
"Segment Coordinates");
149 param++,
"Segment ID");
151 params.uninitialized_single_output_if_required<
float>(param++,
"Segment Width");
153 params.uninitialized_single_output_if_required<
float>(param++,
"Segment Rotation");
155 const bool calculate_r_gon_parameter_field = !r_segment_coordinates.is_empty();
156 const bool calculate_segment_id = !r_segment_id.is_empty();
157 const bool calculate_max_unit_parameter = !r_max_unit_parameter.is_empty();
158 const bool calculate_x_axis_A_angle_bisector = !r_x_axis_A_angle_bisector.is_empty();
161 if (calculate_r_gon_parameter_field || calculate_max_unit_parameter ||
162 calculate_x_axis_A_angle_bisector)
165 calculate_max_unit_parameter,
166 normalize_r_gon_parameter_,
171 if (calculate_r_gon_parameter_field) {
172 r_segment_coordinates[
i] =
float3(out_variables.y, out_variables.x, 0.0f);
174 if (calculate_max_unit_parameter) {
175 r_max_unit_parameter[
i] = out_variables.z;
177 if (calculate_x_axis_A_angle_bisector) {
178 r_x_axis_A_angle_bisector[
i] = out_variables.w;
182 if (calculate_segment_id) {
213 ntype.
ui_name =
"Radial Tiling";
214 ntype.
ui_description =
"Transform Coordinate System for Radial Tiling";
216 ntype.
declare = file_ns::sh_node_radial_tiling_declare;
217 ntype.
draw_buttons = file_ns::node_shader_buts_radial_tiling;
218 ntype.
initfunc = file_ns::node_shader_init_radial_tiling;
221 ntype.
gpu_fn = file_ns::node_shader_gpu_radial_tiling;
#define NODE_STORAGE_FUNCS(StorageT)
#define NODE_CLASS_OP_VECTOR
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
GPUNodeLink * GPU_constant(const float *num)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
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 * MEM_callocN(size_t len, const char *str)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
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 node_shader_buts_radial_tiling(uiLayout *layout, bContext *, PointerRNA *ptr)
static void sh_node_radial_tiling_build_multi_function(NodeMultiFunctionBuilder &builder)
static const char * gpu_shader_get_name()
static void sh_node_radial_tiling_declare(NodeDeclarationBuilder &b)
VecBase< float, 4 > float4
VecBase< float, 2 > float2
float calculate_out_segment_id(float r_gon_sides, float2 coord)
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 register_node_type_sh_radial_tiling()
void sh_geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
void node_free_standard_storage(bNode *node)
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
std::string ui_description
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGPUExecFunction gpu_fn
NodeMultiFunctionBuildFunction build_multi_function
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)