Blender V4.3
COM_algorithm_parallel_reduction.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
8
9#include "GPU_texture.hh"
10
11#include "COM_context.hh"
12
14
15/* --------------------------------------------------------------------
16 * Sum Reductions.
17 */
18
19/* Computes the sum of the red channel of all pixels in the given texture. */
20float sum_red(Context &context, GPUTexture *texture);
21
22/* Computes the sum of the green channel of all pixels in the given texture. */
23float sum_green(Context &context, GPUTexture *texture);
24
25/* Computes the sum of the blue channel of all pixels in the given texture. */
26float sum_blue(Context &context, GPUTexture *texture);
27
28/* Computes the sum of the luminance of all pixels in the given texture, using the given luminance
29 * coefficients to compute the luminance. */
30float sum_luminance(Context &context, GPUTexture *texture, float3 luminance_coefficients);
31
32/* Computes the sum of the logarithm of the luminance of all pixels in the given texture, using the
33 * given luminance coefficients to compute the luminance. */
34float sum_log_luminance(Context &context, GPUTexture *texture, float3 luminance_coefficients);
35
36/* Computes the sum of the colors of all pixels in the given texture. */
37float4 sum_color(Context &context, GPUTexture *texture);
38
39/* --------------------------------------------------------------------
40 * Sum Of Squared Difference Reductions.
41 */
42
43/* Computes the sum of the squared difference between the red channel of all pixels in the given
44 * texture and the given subtrahend. This can be used to compute the standard deviation if the
45 * given subtrahend is the mean. */
46float sum_red_squared_difference(Context &context, GPUTexture *texture, float subtrahend);
47
48/* Computes the sum of the squared difference between the green channel of all pixels in the given
49 * texture and the given subtrahend. This can be used to compute the standard deviation if the
50 * given subtrahend is the mean. */
51float sum_green_squared_difference(Context &context, GPUTexture *texture, float subtrahend);
52
53/* Computes the sum of the squared difference between the blue channel of all pixels in the given
54 * texture and the given subtrahend. This can be used to compute the standard deviation if the
55 * given subtrahend is the mean. */
56float sum_blue_squared_difference(Context &context, GPUTexture *texture, float subtrahend);
57
58/* Computes the sum of the squared difference between the luminance of all pixels in the given
59 * texture and the given subtrahend, using the given luminance coefficients to compute the
60 * luminance. This can be used to compute the standard deviation if the given subtrahend is the
61 * mean. */
62float sum_luminance_squared_difference(Context &context,
63 GPUTexture *texture,
64 float3 luminance_coefficients,
65 float subtrahend);
66
67/* --------------------------------------------------------------------
68 * Maximum Reductions.
69 */
70
71/* Computes the maximum luminance of all pixels in the given texture, using the given luminance
72 * coefficients to compute the luminance. */
73float maximum_luminance(Context &context, GPUTexture *texture, float3 luminance_coefficients);
74
75/* Computes the maximum float value of all pixels in the given texture. */
76float maximum_float(Context &context, GPUTexture *texture);
77
78/* Computes the maximum float of all pixels in the given float texture, limited to the given range.
79 * Values outside of the given range are ignored. If non of the pixel values are in the range, the
80 * lower bound of the range is returned. For instance, if the given range is [-10, 10] and the
81 * image contains the values {2, 5, 11}, the maximum will be 5, since 11 is outside of the range.
82 * This is particularly useful for Z Depth normalization, since Z Depth can contain near infinite
83 * values, so enforcing an upper bound is beneficial. */
84float maximum_float_in_range(Context &context,
85 GPUTexture *texture,
86 float lower_bound,
87 float upper_bound);
88
89/* --------------------------------------------------------------------
90 * Minimum Reductions.
91 */
92
93/* Computes the minimum luminance of all pixels in the given texture, using the given luminance
94 * coefficients to compute the luminance. */
95float minimum_luminance(Context &context, GPUTexture *texture, float3 luminance_coefficients);
96
97/* Computes the minimum float value of all pixels in the given texture. */
98float minimum_float(Context &context, GPUTexture *texture);
99
100/* Computes the minimum float of all pixels in the given float texture, limited to the given range.
101 * Values outside of the given range are ignored. If non of the pixel values are in the range, the
102 * upper bound of the range is returned. For instance, if the given range is [-10, 10] and the
103 * image contains the values {-11, 2, 5}, the minimum will be 2, since -11 is outside of the range.
104 * This is particularly useful for Z Depth normalization, since Z Depth can contain near infinite
105 * values, so enforcing a lower bound is beneficial. */
106float minimum_float_in_range(Context &context,
107 GPUTexture *texture,
108 float lower_bound,
109 float upper_bound);
110
111} // namespace blender::realtime_compositor
float sum_log_luminance(Context &context, GPUTexture *texture, float3 luminance_coefficients)
float sum_blue_squared_difference(Context &context, GPUTexture *texture, float subtrahend)
float maximum_float_in_range(Context &context, GPUTexture *texture, float lower_bound, float upper_bound)
float4 sum_color(Context &context, GPUTexture *texture)
float sum_luminance_squared_difference(Context &context, GPUTexture *texture, float3 luminance_coefficients, float subtrahend)
float minimum_float(Context &context, GPUTexture *texture)
float sum_blue(Context &context, GPUTexture *texture)
float sum_red_squared_difference(Context &context, GPUTexture *texture, float subtrahend)
float sum_luminance(Context &context, GPUTexture *texture, float3 luminance_coefficients)
float sum_red(Context &context, GPUTexture *texture)
float minimum_float_in_range(Context &context, GPUTexture *texture, float lower_bound, float upper_bound)
float maximum_luminance(Context &context, GPUTexture *texture, float3 luminance_coefficients)
float sum_green_squared_difference(Context &context, GPUTexture *texture, float subtrahend)
float sum_green(Context &context, GPUTexture *texture)
float minimum_luminance(Context &context, GPUTexture *texture, float3 luminance_coefficients)
float maximum_float(Context &context, GPUTexture *texture)
VecBase< float, 4 > float4