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"
11 #include "texturing.h"
17 Implements screen-space ambient occlusion.
19 http://en.wikipedia.org/wiki/Screen_Space_Ambient_Occlusion
21 class AmbientOcclusion: public PostProcessor
24 struct Template: PostProcessor::Template
26 class Loader: public DataFile::DerivedObjectLoader<Template, PostProcessor::Template::Loader>
33 float occlusion_radius;
35 float edge_depth_threshold;
39 virtual AmbientOcclusion *create(Resources &, unsigned, unsigned) const;
43 Texture2D rotate_lookup;
44 RenderTarget occlude_target;
46 const Program &occlude_shader;
47 const Program &combine_shader;
48 mutable ProgramData shdata;
50 const Sampler &linear_sampler;
51 const Sampler &nearest_sampler;
54 AmbientOcclusion(Resources &, unsigned, unsigned, float = 1.0f);
57 static float random(unsigned &);
60 void set_n_samples(unsigned);
61 void set_occlusion_radius(float);
62 void set_edge_depth_threshold(float);
64 void set_darkness(float);
66 virtual void render(Renderer &, const Texture2D &, const Texture2D &);