diff options
author | Hans Goudey <h.goudey@me.com> | 2022-11-11 04:14:48 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-11-11 04:41:13 +0300 |
commit | 9465b109af0b70244a36f9e68493e316d9f8b56f (patch) | |
tree | c4d933bf09f8313071556063156538ec3356b24c /source/blender/compositor/realtime_compositor/cached_resources/COM_morphological_distance_feather_weights.hh | |
parent | 026d21a225521670c6b5083da9da61227da69e65 (diff) | |
parent | ca1642cd0c5cdf634fe2022c955d93983de95934 (diff) |
Merge branch 'master' into refactor-mesh-position-genericrefactor-mesh-position-generic
Diffstat (limited to 'source/blender/compositor/realtime_compositor/cached_resources/COM_morphological_distance_feather_weights.hh')
-rw-r--r-- | source/blender/compositor/realtime_compositor/cached_resources/COM_morphological_distance_feather_weights.hh | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/source/blender/compositor/realtime_compositor/cached_resources/COM_morphological_distance_feather_weights.hh b/source/blender/compositor/realtime_compositor/cached_resources/COM_morphological_distance_feather_weights.hh new file mode 100644 index 00000000000..cd6827bdd6b --- /dev/null +++ b/source/blender/compositor/realtime_compositor/cached_resources/COM_morphological_distance_feather_weights.hh @@ -0,0 +1,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 |