Blender V5.3
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#include "kernel/svm/util.h"
9
11
12/* Define macro flags for code adaption. */
13#define ADAPT_TO_SVM
14
15/* The rounded polygon calculation functions are defined in radial_tiling_shared.h. */
17
18/* Undefine macro flags used for code adaption. */
19#undef ADAPT_TO_SVM
20
21template<uint64_t node_feature_mask>
24{
25 const bool calculate_r_gon_parameter_field = stack_valid(node.segment_coordinates_offset);
26 const bool calculate_segment_id = stack_valid(node.segment_id_offset);
27 const bool calculate_max_unit_parameter = stack_valid(node.max_unit_parameter_offset);
28 const bool calculate_x_axis_A_angle_bisector = stack_valid(node.x_axis_A_angle_bisector_offset);
29
30 const float3 coord = stack_load(stack, node.vector);
31 const float r_gon_sides = stack_load(stack, node.r_gon_sides);
32 const float r_gon_roundness = stack_load(stack, node.r_gon_roundness);
33
34 if (calculate_r_gon_parameter_field || calculate_max_unit_parameter ||
35 calculate_x_axis_A_angle_bisector)
36 {
37 float4 out_variables = calculate_out_variables(calculate_r_gon_parameter_field,
38 calculate_max_unit_parameter,
39 node.normalize_r_gon_parameter,
40 fmaxf(r_gon_sides, 2.0f),
41 clamp(r_gon_roundness, 0.0f, 1.0f),
42 make_float2(coord.x, coord.y));
43
44 if (calculate_r_gon_parameter_field) {
46 node.segment_coordinates_offset,
47 make_float3(out_variables.y, out_variables.x, 0.0f));
48 }
49 if (calculate_max_unit_parameter) {
50 stack_store_float(stack, node.max_unit_parameter_offset, out_variables.z);
51 }
52 if (calculate_x_axis_A_angle_bisector) {
53 stack_store_float(stack, node.x_axis_A_angle_bisector_offset, out_variables.w);
54 }
55 }
56
57 if (calculate_segment_id) {
59 stack,
60 node.segment_id_offset,
61 calculate_out_segment_id(fmaxf(r_gon_sides, 2.0f), make_float2(coord.x, coord.y)));
62 }
63}
64
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_inline bool stack_valid(const uint a)
ccl_device_inline T stack_load(const ccl_private float *stack, const uint a)
#define ccl_restrict
#define ccl_private
#define ccl_global
#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 void svm_node_radial_tiling(ccl_private float *ccl_restrict stack, const ccl_global SVMNodeRadialTiling &ccl_restrict node)
#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