]> git.tdb.fi Git - libs/gl.git/blobdiff - source/ambientocclusion.h
Give both color and depth buffers to postprocessors
[libs/gl.git] / source / ambientocclusion.h
diff --git a/source/ambientocclusion.h b/source/ambientocclusion.h
new file mode 100644 (file)
index 0000000..1866bae
--- /dev/null
@@ -0,0 +1,53 @@
+/* $Id$
+
+This file is part of libmspgl
+Copyright © 2010  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef MSP_GL_AMBIENTOCCLUSION_H_
+#define MSP_GL_AMBIENTOCCLUSION_H_
+
+#include "framebuffer.h"
+#include "mesh.h"
+#include "postprocessor.h"
+#include "program.h"
+#include "programdata.h"
+#include "texture2d.h"
+#include "texturing.h"
+
+namespace Msp {
+namespace GL {
+
+/**
+Implements screen-space ambient occlusion.
+
+http://en.wikipedia.org/wiki/Screen_Space_Ambient_Occlusion
+*/
+class AmbientOcclusion: public PostProcessor
+{
+private:
+       Texture2D occlusion;
+       Texture2D rotate_lookup;
+       Framebuffer fbo;
+       Texturing occlude_texturing;
+       Program occlude_shader;
+       ProgramData occlude_shdata;
+       Texturing combine_texturing;
+       Program combine_shader;
+       ProgramData combine_shdata;
+       Mesh quad;
+       float darkness;
+
+public:
+       AmbientOcclusion(unsigned, unsigned, float);
+
+       void set_darkness(float);
+
+       virtual void render(const Texture2D &, const Texture2D &);
+};
+
+} // namespace GL
+} // namespace Msp
+
+#endif