Blender V5.0
radial_tiling.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024-2025 Blender Authors
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
8
9/* Define macro flags for code adaption. */
10#define ADAPT_TO_SVM
11
12/* The rounded polygon calculation functions are defined in radial_tiling_shared.h. */
14
15/* Undefine macro flags used for code adaption. */
16#undef ADAPT_TO_SVM
17
27
28template<uint node_feature_mask>
30{
32
33 uint normalize_r_gon_parameter = node.y;
34
36 node.z, &(so.vector), &(so.r_gon_sides), &(so.r_gon_roundness), &(so.segment_coordinates));
38 node.w, &(so.segment_id), &(so.max_unit_parameter), &(so.x_axis_A_angle_bisector));
39
40 bool calculate_r_gon_parameter_field = stack_valid(so.segment_coordinates);
41 bool calculate_segment_id = stack_valid(so.segment_id);
42 bool calculate_max_unit_parameter = stack_valid(so.max_unit_parameter);
43 bool calculate_x_axis_A_angle_bisector = stack_valid(so.x_axis_A_angle_bisector);
44
45 float3 coord = stack_load_float3(stack, so.vector);
46 float r_gon_sides = stack_load_float(stack, so.r_gon_sides);
47 float r_gon_roundness = stack_load_float(stack, so.r_gon_roundness);
48
49 if (calculate_r_gon_parameter_field || calculate_max_unit_parameter ||
50 calculate_x_axis_A_angle_bisector)
51 {
52 float4 out_variables = calculate_out_variables(calculate_r_gon_parameter_field,
53 calculate_max_unit_parameter,
54 normalize_r_gon_parameter,
55 fmaxf(r_gon_sides, 2.0f),
56 clamp(r_gon_roundness, 0.0f, 1.0f),
57 make_float2(coord.x, coord.y));
58
59 if (calculate_r_gon_parameter_field) {
61 stack, so.segment_coordinates, make_float3(out_variables.y, out_variables.x, 0.0f));
62 }
63 if (calculate_max_unit_parameter) {
64 stack_store_float(stack, so.max_unit_parameter, out_variables.z);
65 }
66 if (calculate_x_axis_A_angle_bisector) {
67 stack_store_float(stack, so.x_axis_A_angle_bisector, out_variables.w);
68 }
69 }
70
71 if (calculate_segment_id) {
73 stack,
74 so.segment_id,
75 calculate_out_segment_id(fmaxf(r_gon_sides, 2.0f), make_float2(coord.x, coord.y)));
76 }
77
78 return offset;
79}
80
unsigned int uint
ccl_device_inline float stack_load_float(const ccl_private float *stack, const uint a)
ccl_device_inline void stack_store_float(ccl_private float *stack, const uint a, const float f)
ccl_device_inline void stack_store_float3(ccl_private float *stack, const uint a, const float3 f)
ccl_device_forceinline void svm_unpack_node_uchar3(const uint i, ccl_private uint *x, ccl_private uint *y, ccl_private uint *z)
ccl_device_forceinline void svm_unpack_node_uchar4(const uint i, ccl_private uint *x, ccl_private uint *y, ccl_private uint *z, ccl_private uint *w)
ccl_device_inline bool stack_valid(const uint a)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 stack_load_float3(const ccl_private float *stack, const uint a)
#define ccl_private
#define ccl_device_noinline
#define CCL_NAMESPACE_END
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
constexpr T clamp(T, U, U) RET
ccl_device_noinline int svm_node_radial_tiling(ccl_private float *stack, uint4 node, int offset)
#define fmaxf
#define make_float2
ccl_device 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)
ccl_device float calculate_out_segment_id(float r_gon_sides, float2 coord)
float y
Definition sky_math.h:136
float x
Definition sky_math.h:136
float y
Definition sky_math.h:225
float z
Definition sky_math.h:225
float x
Definition sky_math.h:225
float w
Definition sky_math.h:225
uint y
Definition types_uint4.h:13
uint z
Definition types_uint4.h:13
uint w
Definition types_uint4.h:13