]> git.tdb.fi Git - libs/gl.git/blob - source/effects/bloom.h
Use default member initializers for simple types
[libs/gl.git] / source / effects / bloom.h
1 #ifndef MSP_GL_BLOOM_H_
2 #define MSP_GL_BLOOM_H_
3
4 #include "postprocessor.h"
5 #include "programdata.h"
6 #include "rendertarget.h"
7
8 namespace Msp {
9 namespace GL {
10
11 class Program;
12
13 /**
14 The Bloom post-processing effect causes very bright areas of the image to bleed
15 into surrounding pixels.  Commonly used together with HDR rendering.
16
17 The technique used is to gaussian blur the image and then blend the result with
18 the original image.  With suitable parameters, this effect may also be used as
19 a blur filter.
20 */
21 class Bloom: public PostProcessor
22 {
23 public:
24         struct Template: public PostProcessor::Template
25         {
26                 class Loader: public DataFile::DerivedObjectLoader<Template, PostProcessor::Template::Loader>
27                 {
28                 public:
29                         Loader(Template &);
30                 };
31
32                 float radius = 2.0f;
33                 float strength = 0.2f;
34
35                 virtual Bloom *create(unsigned, unsigned) const;
36         };
37
38 private:
39         RenderTarget *target[2];
40         ProgramData common_shdata;
41         const Program &blur_shader;
42         ProgramData blur_shdata[2];
43         const Program &combine_shader;
44         const Mesh &quad;
45         const Sampler &nearest_sampler;
46         const Sampler &linear_sampler;
47
48 public:
49         Bloom(unsigned, unsigned);
50         ~Bloom();
51
52         /** Sets the σ value of the gaussian blur.  Values much larger than 4.0 are
53         likely to cause artifacts. */
54         void set_radius(float);
55
56         /** Sets the blend factor between original and blurred images.  Larger
57         values mean more blurriness. */
58         void set_strength(float);
59
60         virtual void render(Renderer &, const Texture2D &, const Texture2D &);
61
62         virtual void set_debug_name(const std::string &);
63 };
64
65 } // namespace GL
66 } // namespace Msp
67
68 #endif