1 #ifndef MSP_GL_AMBIENTOCCLUSION_H_
2 #define MSP_GL_AMBIENTOCCLUSION_H_
4 #include "postprocessor.h"
5 #include "programdata.h"
6 #include "rendertarget.h"
14 Implements screen-space ambient occlusion.
16 http://en.wikipedia.org/wiki/Screen_Space_Ambient_Occlusion
18 class AmbientOcclusion: public PostProcessor
21 struct Template: PostProcessor::Template
23 class Loader: public DataFile::DerivedObjectLoader<Template, PostProcessor::Template::Loader>
29 unsigned n_samples = 16;
30 float occlusion_radius = 0.5f;
31 float darkness = 1.0f;
32 float edge_depth_threshold = 0.1f;
34 virtual AmbientOcclusion *create(unsigned, unsigned) const;
38 const Texture2D &rotate_lookup;
39 RenderTarget occlude_target;
40 const Program &occlude_shader;
41 const Program &combine_shader;
42 mutable ProgramData shdata;
44 const Sampler &linear_sampler;
45 const Sampler &nearest_clamp_sampler;
46 const Sampler &nearest_sampler;
49 AmbientOcclusion(unsigned, unsigned, float = 1.0f);
52 static const Texture2D &get_or_create_rotate_lookup();
53 static float radical_inverse(unsigned);
56 void set_n_samples(unsigned);
57 void set_occlusion_radius(float);
58 void set_edge_depth_threshold(float);
60 void set_darkness(float);
62 virtual void render(Renderer &, const Texture2D &, const Texture2D &);
64 virtual void set_debug_name(const std::string &);