]> git.tdb.fi Git - libs/gl.git/blob - source/bloom.h
Give both color and depth buffers to postprocessors
[libs/gl.git] / source / bloom.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2009  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 "program.h"
16 #include "programdata.h"
17
18 namespace Msp {
19 namespace GL {
20
21 /**
22 The Bloom post-processing effect causes very bright areas of the image to bleed
23 into surrounding pixels.  Commonly used together with HDR rendering.
24
25 The technique used is to gaussian blur the image and then blend the result with
26 the original image.  With suitable parameters, this effect may also be used as
27 a blur filter.
28 */
29 class Bloom: public PostProcessor
30 {
31 private:
32         Framebuffer fbo;
33         Texture2D tex[2];
34         Program blur_shader;
35         ProgramData blur_shdata[2];
36         Program combine_shader;
37         ProgramData combine_shdata;
38         Mesh quad;
39
40 public:
41         Bloom(unsigned, unsigned);
42         
43         /** Sets the σ value of the gaussian blur.  Values much larger than 4.0 are
44         likely to cause artifacts. */
45         void set_radius(float);
46
47         /** Sets the blend factor between original and blurred images.  Larger
48         values mean more blurriness. */
49         void set_strength(float);
50
51         virtual void render(const Texture2D &, const Texture2D &);
52 };
53
54 } // namespace GL
55 } // namespace Msp
56
57 #endif