Blender V4.3
COM_morphological_distance_feather_weights.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
7#include <cstdint>
8#include <memory>
9
10#include "BLI_map.hh"
11
12#include "GPU_shader.hh"
13#include "GPU_texture.hh"
14
16
18
19class Context;
20
21/* ------------------------------------------------------------------------------------------------
22 * Morphological Distance Feather Key.
23 */
25 public:
26 int type;
27 float radius;
28
29 MorphologicalDistanceFeatherWeightsKey(int type, float radius);
30
31 uint64_t hash() const;
32};
33
36
37/* -------------------------------------------------------------------------------------------------
38 * Morphological Distance Feather Weights.
39 *
40 * A cached resource that computes and caches 1D GPU textures containing the weights of the
41 * separable Gaussian filter of the given radius as well as an inverse distance falloff of the
42 * given type and radius. The weights and falloffs are symmetric, because the Gaussian and falloff
43 * functions are all even functions. Consequently, only the positive half of the filter is computed
44 * and the shader takes that into consideration. */
46 private:
47 GPUTexture *weights_texture_ = nullptr;
48 GPUTexture *distance_falloffs_texture_ = nullptr;
49
50 public:
51 MorphologicalDistanceFeatherWeights(Context &context, int type, int radius);
52
54
55 void compute_weights(Context &context, int radius);
56
57 void compute_distance_falloffs(Context &context, int type, int radius);
58
59 void bind_weights_as_texture(GPUShader *shader, const char *texture_name) const;
60
61 void unbind_weights_as_texture() const;
62
63 void bind_distance_falloffs_as_texture(GPUShader *shader, const char *texture_name) const;
64
66};
67
68/* ------------------------------------------------------------------------------------------------
69 * Morphological Distance Feather Key.
70 */
72 private:
74 map_;
75
76 public:
77 void reset() override;
78
79 /* Check if there is an available MorphologicalDistanceFeatherWeights cached resource with the
80 * given parameters in the container, if one exists, return it, otherwise, return a newly created
81 * one and add it to the container. In both cases, tag the cached resource as needed to keep it
82 * cached for the next evaluation. */
83 MorphologicalDistanceFeatherWeights &get(Context &context, int type, int radius);
84};
85
86} // namespace blender::realtime_compositor
struct GPUShader GPUShader
MorphologicalDistanceFeatherWeights & get(Context &context, int type, int radius)
void bind_distance_falloffs_as_texture(GPUShader *shader, const char *texture_name) const
void bind_weights_as_texture(GPUShader *shader, const char *texture_name) const
local_group_size(16, 16) .push_constant(Type b
bool operator==(const BokehKernelKey &a, const BokehKernelKey &b)
unsigned __int64 uint64_t
Definition stdint.h:90