]> git.tdb.fi Git - libs/gl.git/blob - source/ambientocclusion.h
b6daa776d6af8804f5cf1186cb7974d1b5f3783d
[libs/gl.git] / source / ambientocclusion.h
1 #ifndef MSP_GL_AMBIENTOCCLUSION_H_
2 #define MSP_GL_AMBIENTOCCLUSION_H_
3
4 #include "framebuffer.h"
5 #include "mesh.h"
6 #include "postprocessor.h"
7 #include "program.h"
8 #include "programdata.h"
9 #include "rendertarget.h"
10 #include "texture2d.h"
11 #include "texturing.h"
12
13 namespace Msp {
14 namespace GL {
15
16 /**
17 Implements screen-space ambient occlusion.
18
19 http://en.wikipedia.org/wiki/Screen_Space_Ambient_Occlusion
20 */
21 class AmbientOcclusion: public PostProcessor
22 {
23 private:
24         Texture2D rotate_lookup;
25         RenderTarget occlude_target;
26         Texturing texturing;
27         Program occlude_shader;
28         Program combine_shader;
29         mutable ProgramData shdata;
30         const Mesh &quad;
31
32 public:
33         AmbientOcclusion(unsigned, unsigned, float = 1.0f);
34
35 private:
36         static float random(unsigned &);
37
38 public:
39         void set_n_samples(unsigned);
40         void set_occlusion_radius(float);
41
42         // Deprecated
43         void set_depth_ratio(float);
44
45         void set_darkness(float);
46
47         virtual void render(Renderer &, const Texture2D &, const Texture2D &);
48 };
49
50 } // namespace GL
51 } // namespace Msp
52
53 #endif