Blender V5.3
draw_curves_length_intercept.bsl.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
11
12#pragma once
13
14#include "gpu_shader_offset_indices_lib.glsl"
15
16namespace curves {
17
23
27
28 /* Run on the evaluated position and compute the intercept time with the curve and the total
29 * curve length. */
30 void evaluate_length_and_time(const IndexRange evaluated_points, const int curve_index)
31 {
32 float distance_along_curve = 0.0f;
33 evaluated_time_buf[evaluated_points.first()] = 0.0f;
34 for (int i = 1; i < evaluated_points.size(); i++) {
35 int p = evaluated_points.start() + i;
36 distance_along_curve += distance(evaluated_positions_radii_buf[p].xyz,
38 evaluated_time_buf[p] = distance_along_curve;
39 }
40 for (int i = 1; i < evaluated_points.size(); i++) {
41 int p = evaluated_points.start() + i;
42 evaluated_time_buf[p] /= distance_along_curve;
43 }
44 curves_length_buf[curve_index] = distance_along_curve;
45 }
46};
47
49 [[resource_table]] EvalIntercept &srt, [[global_invocation_id]] const uint3 global_id)
50{
51 if (global_id.x >= uint(srt.curves_count)) {
52 return;
53 }
54 int curve_index = int(global_id.x) + srt.curves_start;
55
56 IndexRange evaluated_points = offset_indices::load_range_from_buffer(
57 srt.evaluated_points_by_curve_buf, curve_index);
58
59 if (srt.use_cyclic) {
60 evaluated_points = IndexRange{evaluated_points.start() + curve_index,
61 evaluated_points.size() + 1};
62 }
63
64 srt.evaluate_length_and_time(evaluated_points, curve_index);
65}
66
67} // namespace curves
68
#define CURVES_PER_THREADGROUP
#define EVALUATED_POS_RAD_SLOT
#define EVALUATED_TIME_SLOT
#define EVALUATED_POINT_SLOT
#define CURVES_LENGTH_SLOT
PipelineCompute draw_curves_evaluate_length_intercept(curves::eval_intercept)
#define storage(slot, qualifiers)
#define push_constant
#define resource_table
#define global_invocation_id
#define compute
#define local_size(...)
float distance(float, float) RET
void eval_intercept(EvalIntercept &srt, const uint3 global_id)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
void evaluate_length_and_time(const IndexRange evaluated_points, const int curve_index)