]> git.tdb.fi Git - libs/gl.git/blob - source/bloom.h
2900175ff1f8ac6e34b52dfc994572aeaacbbe74
[libs/gl.git] / source / bloom.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2009-2011  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GL_BLOOM_H_
9 #define MSP_GL_BLOOM_H_
10
11 #include "framebuffer.h"
12 #include "mesh.h"
13 #include "postprocessor.h"
14 #include "texture2d.h"
15 #include "texturing.h"
16 #include "program.h"
17 #include "programdata.h"
18
19 namespace Msp {
20 namespace GL {
21
22 /**
23 The Bloom post-processing effect causes very bright areas of the image to bleed
24 into surrounding pixels.  Commonly used together with HDR rendering.
25
26 The technique used is to gaussian blur the image and then blend the result with
27 the original image.  With suitable parameters, this effect may also be used as
28 a blur filter.
29 */
30 class Bloom: public PostProcessor
31 {
32 private:
33         Framebuffer fbo;
34         Texture2D tex[2];
35         Program blur_shader;
36         ProgramData blur_shdata_common;
37         ProgramData blur_shdata_x;
38         ProgramData blur_shdata_y;
39         Program combine_shader;
40         ProgramData combine_shdata;
41         Texturing combine_texturing;
42         Mesh quad;
43
44 public:
45         Bloom(unsigned, unsigned);
46         
47         /** Sets the σ value of the gaussian blur.  Values much larger than 4.0 are
48         likely to cause artifacts. */
49         void set_radius(float);
50
51         /** Sets the blend factor between original and blurred images.  Larger
52         values mean more blurriness. */
53         void set_strength(float);
54
55         virtual void render(const Texture2D &, const Texture2D &);
56 };
57
58 } // namespace GL
59 } // namespace Msp
60
61 #endif