]> git.tdb.fi Git - libs/gl.git/blob - source/ambientocclusion.h
4affd04987aef3f1b6ce6c5c71b99bf12a2a4b64
[libs/gl.git] / source / ambientocclusion.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2010  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GL_AMBIENTOCCLUSION_H_
9 #define MSP_GL_AMBIENTOCCLUSION_H_
10
11 #include "framebuffer.h"
12 #include "mesh.h"
13 #include "postprocessor.h"
14 #include "program.h"
15 #include "programdata.h"
16 #include "texture2d.h"
17 #include "texturing.h"
18
19 namespace Msp {
20 namespace GL {
21
22 /**
23 Implements screen-space ambient occlusion.
24
25 http://en.wikipedia.org/wiki/Screen_Space_Ambient_Occlusion
26 */
27 class AmbientOcclusion: public PostProcessor
28 {
29 private:
30         Texture2D occlusion;
31         Texture2D rotate_lookup;
32         Framebuffer fbo;
33         Texturing occlude_texturing;
34         Program occlude_shader;
35         ProgramData occlude_shdata;
36         Texturing combine_texturing;
37         Program combine_shader;
38         ProgramData combine_shdata;
39         Mesh quad;
40
41 public:
42         AmbientOcclusion(unsigned, unsigned, float);
43
44         void set_depth_ratio(float);
45         void set_darkness(float);
46
47         virtual void render(const Texture2D &, const Texture2D &);
48 };
49
50 } // namespace GL
51 } // namespace Msp
52
53 #endif