1 #ifndef MSP_GL_AMBIENTOCCLUSION_H_
2 #define MSP_GL_AMBIENTOCCLUSION_H_
4 #include "framebuffer.h"
6 #include "postprocessor.h"
8 #include "programdata.h"
9 #include "rendertarget.h"
10 #include "texture2d.h"
16 Implements screen-space ambient occlusion.
18 http://en.wikipedia.org/wiki/Screen_Space_Ambient_Occlusion
20 class AmbientOcclusion: public PostProcessor
23 struct Template: PostProcessor::Template
25 class Loader: public DataFile::DerivedObjectLoader<Template, PostProcessor::Template::Loader>
32 float occlusion_radius;
34 float edge_depth_threshold;
38 virtual AmbientOcclusion *create(Resources &, unsigned, unsigned) const;
42 Texture2D rotate_lookup;
43 RenderTarget occlude_target;
44 const Program &occlude_shader;
45 const Program &combine_shader;
46 mutable ProgramData shdata;
48 const Sampler &linear_sampler;
49 const Sampler &nearest_sampler;
52 AmbientOcclusion(Resources &, unsigned, unsigned, float = 1.0f);
55 static float random(unsigned &);
58 void set_n_samples(unsigned);
59 void set_occlusion_radius(float);
60 void set_edge_depth_threshold(float);
62 void set_darkness(float);
64 virtual void render(Renderer &, const Texture2D &, const Texture2D &);