]> git.tdb.fi Git - libs/gl.git/blob - source/bloom.h
Remove dynamic allocation from VertexFormat
[libs/gl.git] / source / 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 "texturing.h"
9 #include "program.h"
10 #include "programdata.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 private:
26         Framebuffer fbo[2];
27         Texture2D tex[2];
28         Program blur_shader;
29         ProgramData blur_shdata_common;
30         ProgramData blur_shdata[2];
31         Program combine_shader;
32         ProgramData combine_shdata;
33         Texturing combine_texturing;
34         const Mesh &quad;
35
36 public:
37         Bloom(unsigned, unsigned);
38
39         /** Sets the σ value of the gaussian blur.  Values much larger than 4.0 are
40         likely to cause artifacts. */
41         void set_radius(float);
42
43         /** Sets the blend factor between original and blurred images.  Larger
44         values mean more blurriness. */
45         void set_strength(float);
46
47         virtual void render(Renderer &, const Texture2D &, const Texture2D &);
48 };
49
50 } // namespace GL
51 } // namespace Msp
52
53 #endif