44 #include <ACG/GL/acg_glew.hh>
48 #include <ACG/GL/ScreenQuad.hh>
49 #include <ACG/GL/ShaderCache.hh>
57 PostProcessorDoF::PostProcessorDoF()
63 PostProcessorDoF::~PostProcessorDoF()
68 QString PostProcessorDoF::checkOpenGL()
71 return QString(
"Depth of Field plugin requires OpenGL 4.3!");
86 glDisable(GL_DEPTH_TEST);
94 int w = _input[0]->width;
95 int h = _input[0]->height;
101 if (scene32F_.getWidth() != w || scene32F_.getHeight() != h)
104 scene32F_.setStorage(1, GL_RGBA32F, w, h);
105 scene32F_.parameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST);
106 scene32F_.parameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST);
109 sat32F_.setStorage(1, GL_RGBA32F, w, h);
110 sat32F_.parameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST);
111 sat32F_.parameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST);
114 scene32F_.bindAsImage(0, GL_READ_WRITE);
116 glActiveTexture(GL_TEXTURE0);
117 glBindTexture(GL_TEXTURE_2D, _input[0]->colorTex_);
122 if (!plan2D_ || plan2D_->getRowPlan()->width() != w || plan2D_->getRowPlan()->height() != h)
125 plan2D_ =
new SATPlan(w,h, GL_RGBA32F, 128);
127 plan2D_->execute(&scene32F_, &sat32F_);
134 glBindFramebuffer(GL_FRAMEBUFFER, _output.fbo_);
135 glDrawBuffer(_output.drawBuffer_);
138 glColorMask(1,1,1,1);
148 ACG::Vec2f clipPlanes = _input[0]->proj_.extract_planes();
149 progDoF->
setUniform(
"g_ClipPlanes", clipPlanes);
150 printf(
"n/f: %f %f \n", clipPlanes[0], clipPlanes[1]);
152 glActiveTexture(GL_TEXTURE1);
153 glBindTexture(GL_TEXTURE_2D, _input[0]->depthTex_);
155 scene32F_.bind(GL_TEXTURE2);
157 sat32F_.bind(GL_TEXTURE0);
161 ScreenQuad::draw(progDoF);
164 ScreenQuad::drawTexture2D(_input[0]->colorTex_);
169 #if QT_VERSION < 0x050000
static void draw(GLSL::Program *_prog=0)
Draw the screen quad.
static ShaderCache * getInstance()
Return instance of the ShaderCache singleton.
Namespace providing different geometric functions concerning angles.
bool openGLVersion(const int _major, const int _minor)
void setUniform(const char *_name, GLint _value)
Set int uniform to specified value.
GLSL::Program * getProgram(const ShaderGenDesc *_desc, const std::vector< unsigned int > &_mods)
Query a dynamically generated program from cache.
void use()
Enables the program object for using.