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