blob: cd6827bdd6b1212ee6a13777e508a49ef97e5da4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include <cstdint>
#include "GPU_shader.h"
#include "GPU_texture.h"
#include "COM_cached_resource.hh"
namespace blender::realtime_compositor {
/* ------------------------------------------------------------------------------------------------
* Morphological Distance Feather Key.
*/
class MorphologicalDistanceFeatherWeightsKey {
public:
int type;
float radius;
MorphologicalDistanceFeatherWeightsKey(int type, float radius);
uint64_t hash() const;
};
bool operator==(const MorphologicalDistanceFeatherWeightsKey &a,
const MorphologicalDistanceFeatherWeightsKey &b);
/* -------------------------------------------------------------------------------------------------
* Morphological Distance Feather Weights.
*
* A cached resource that computes and caches 1D GPU textures containing the weights of the
* separable Gaussian filter of the given radius as well as an inverse distance falloff of the
* given type and radius. The weights and falloffs are symmetric, because the Gaussian and falloff
* functions are all even functions. Consequently, only the positive half of the filter is computed
* and the shader takes that into consideration. */
class MorphologicalDistanceFeatherWeights : public CachedResource {
private:
GPUTexture *weights_texture_ = nullptr;
GPUTexture *distance_falloffs_texture_ = nullptr;
public:
MorphologicalDistanceFeatherWeights(int type, int radius);
~MorphologicalDistanceFeatherWeights();
void compute_weights(int radius);
void compute_distance_falloffs(int type, int radius);
void bind_weights_as_texture(GPUShader *shader, const char *texture_name) const;
void unbind_weights_as_texture() const;
void bind_distance_falloffs_as_texture(GPUShader *shader, const char *texture_name) const;
void unbind_distance_falloffs_as_texture() const;
};
} // namespace blender::realtime_compositor
|