Welcome to mirror list, hosted at ThFree Co, Russian Federation.

COM_symmetric_blur_weights.hh « cached_resources « realtime_compositor « compositor « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 05d3c7c6f3ec4afc93c569ba7111d0c5e4045fd2 (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
/* SPDX-License-Identifier: GPL-2.0-or-later */

#pragma once

#include <cstdint>

#include "BLI_math_vec_types.hh"

#include "GPU_shader.h"
#include "GPU_texture.h"

#include "COM_cached_resource.hh"

namespace blender::realtime_compositor {

/* ------------------------------------------------------------------------------------------------
 * Symmetric Blur Weights Key.
 */
class SymmetricBlurWeightsKey {
 public:
  int type;
  float2 radius;

  SymmetricBlurWeightsKey(int type, float2 radius);

  uint64_t hash() const;
};

bool operator==(const SymmetricBlurWeightsKey &a, const SymmetricBlurWeightsKey &b);

/* -------------------------------------------------------------------------------------------------
 * Symmetric Blur Weights.
 *
 * A cached resource that computes and caches a 2D GPU texture containing the weights of the filter
 * of the given type and radius. The filter is assumed to be symmetric, because the filter
 * functions are evaluated on the normalized distance to the center. Consequently, only the upper
 * right quadrant are computed and the shader takes that into consideration. */
class SymmetricBlurWeights : public CachedResource {
 private:
  GPUTexture *texture_ = nullptr;

 public:
  SymmetricBlurWeights(int type, float2 radius);

  ~SymmetricBlurWeights();

  void bind_as_texture(GPUShader *shader, const char *texture_name) const;

  void unbind_as_texture() const;
};

}  // namespace blender::realtime_compositor