Commit a28efb4c authored by Christopher Tenter's avatar Christopher Tenter

add several blur postprocessors

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free-Staging@20055 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 8cdd56da
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 17080 $ *
* $LastChangedBy: moeller $ *
* $Date: 2013-07-19 12:58:31 +0200 (Fri, 19 Jul 2013) $ *
* *
\*===========================================================================*/
#include <ACG/GL/acg_glew.hh>
#include "PostProcessorBilateralBlur.hh"
#include <ACG/GL/ScreenQuad.hh>
#include <ACG/GL/ShaderCache.hh>
#include <ACG/GL/GLFormatInfo.hh>
#include <QDialog>
#include <QColor>
#include <QLabel>
#include <QSlider>
#include <QVBoxLayout>
#include <ACG/QtWidgets/QtColorChooserButton.hh>
PostProcessorBilateralBlur::PostProcessorBilateralBlur()
: blur_(32, 32, 4, 2.0f, 2.0f, GL_RGBA)
{
}
PostProcessorBilateralBlur::~PostProcessorBilateralBlur()
{
}
QString PostProcessorBilateralBlur::checkOpenGL()
{
if (!ACG::openGLVersion(3,0))
return QString("SSAO plugin requires OpenGL 3.0!");
return QString("");
}
void PostProcessorBilateralBlur::postProcess( ACG::GLState* _glstate, const std::vector<const PostProcessorInput*>& _input, const PostProcessorOutput& _output )
{
glBindFramebuffer(GL_FRAMEBUFFER, _output.fbo_);
glDrawBuffer(_output.drawBuffer_);
glDepthMask(1);
glColorMask(1,1,1,1);
blur_.resizeInput(_input[0]->width, _input[0]->height);
blur_.setParams(_glstate->projection(), _input[0]->depthTex_);
blur_.execute(_input[0]->colorTex_, 0, 0, 0);
}
QAction* PostProcessorBilateralBlur::optionsAction()
{
QAction * action = new QAction("Gaussian Blur Options" , this );
connect(action,SIGNAL(triggered( bool )),this,SLOT(optionDialog( bool )));
return action;
}
void PostProcessorBilateralBlur::optionDialog( bool )
{
//generate widget
QDialog* optionsDlg = new QDialog();
QVBoxLayout* layout = new QVBoxLayout();
layout->setAlignment(Qt::AlignTop);
QColor curColor;
curColor.setRgbF(0.3f, 0.2f, 0.7f);
QLabel* label = new QLabel(tr("Radius [1, 32]:"));
layout->addWidget(label);
QSlider* radiusSlider = new QSlider(Qt::Horizontal);
radiusSlider->setRange(1, 32);
radiusSlider->setValue(8);
radiusSlider->setTracking(true);
layout->addWidget(radiusSlider);
label = new QLabel(tr("spatial sigma [0.1, 20.0]:"));
layout->addWidget(label);
QSlider* sigmaSlider = new QSlider(Qt::Horizontal);
sigmaSlider->setRange(1, 200);
sigmaSlider->setValue(10);
sigmaSlider->setTracking(true);
layout->addWidget(sigmaSlider);
label = new QLabel(tr("linear depth sigma [0.1, 20.0]:"));
layout->addWidget(label);
QSlider* sigmaRSlider = new QSlider(Qt::Horizontal);
sigmaRSlider->setRange(1, 200);
sigmaRSlider->setValue(10);
sigmaRSlider->setTracking(true);
layout->addWidget(sigmaRSlider);
optionsDlg->setLayout(layout);
connect(radiusSlider, SIGNAL(sliderMoved(int)), this, SLOT(radiusChanged(int)));
connect(sigmaSlider, SIGNAL(sliderMoved(int)), this, SLOT(sigmaSChanged(int)));
connect(sigmaRSlider, SIGNAL(sliderMoved(int)), this, SLOT(sigmaRChanged(int)));
optionsDlg->show();
}
void PostProcessorBilateralBlur::radiusChanged( int _radius )
{
ACG::Vec2f sigma = blur_.sigma();
blur_.setKernel(_radius, sigma[0], sigma[1]);
}
void PostProcessorBilateralBlur::sigmaSChanged( int _val )
{
ACG::Vec2f sigma = blur_.sigma();
sigma[0] = float(_val) * 0.1f;
blur_.setKernel(blur_.radius(), sigma[0], sigma[1]);
}
void PostProcessorBilateralBlur::sigmaRChanged( int _val )
{
ACG::Vec2f sigma = blur_.sigma();
sigma[1] = float(_val) * 0.1f;
blur_.setKernel(blur_.radius(), sigma[0], sigma[1]);
}
#if QT_VERSION < 0x050000
Q_EXPORT_PLUGIN2( postprocessorbilateralblurplugin , PostProcessorBilateralBlur );
#endif
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 17080 $ *
* $LastChangedBy: moeller $ *
* $Date: 2013-07-19 12:58:31 +0200 (Fri, 19 Jul 2013) $ *
* *
\*===========================================================================*/
#include <QObject>
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/PostProcessorInterface.hh>
#include <ACG/GL/globjects.hh>
#include <ACG/ShaderUtils/GLSLShader.hh>
#include <ACG/GL/FBO.hh>
#include <vector>
#include <ACG/GL/FilterKernels.hh>
class PostProcessorBilateralBlur : public QObject, BaseInterface, PostProcessorInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
Q_INTERFACES(PostProcessorInterface)
#if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-PostProcessorBilateralBlur")
#endif
public:
PostProcessorBilateralBlur();
~PostProcessorBilateralBlur();
public :
QString name() { return (QString("Bilateral Blur Postprocessor Plugin")); };
QString description( ) { return (QString(tr("Separable bilateral blur"))); };
public slots:
QString version() { return QString("1.0"); };
QAction* optionsAction();
private slots:
void postProcess(ACG::GLState* _glstate, const std::vector<const PostProcessorInput*>& _input, const PostProcessorOutput& _output);
QString postProcessorName() {return QString("Bilateral Blur");}
QString checkOpenGL();
void optionDialog(bool);
void radiusChanged(int);
void sigmaSChanged(int);
void sigmaRChanged(int);
private:
ACG::BilateralBlurFilter blur_;
};
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 17080 $ *
* $LastChangedBy: moeller $ *
* $Date: 2013-07-19 12:58:31 +0200 (Fri, 19 Jul 2013) $ *
* *
\*===========================================================================*/
#include <ACG/GL/acg_glew.hh>
#include "PostProcessorGaussBlur.hh"
#include <ACG/GL/ScreenQuad.hh>
#include <ACG/GL/ShaderCache.hh>
#include <ACG/GL/GLFormatInfo.hh>
#include <QDialog>
#include <QColor>
#include <QLabel>
#include <QSlider>
#include <QVBoxLayout>
#include <ACG/QtWidgets/QtColorChooserButton.hh>
PostProcessorGaussBlur::PostProcessorGaussBlur()
: blurGauss_(32, 32, 4, 2.0f, GL_RGBA)
{
}
PostProcessorGaussBlur::~PostProcessorGaussBlur()
{
}
QString PostProcessorGaussBlur::checkOpenGL()
{
if (!ACG::openGLVersion(3,0))
return QString("SSAO plugin requires OpenGL 3.0!");
return QString("");
}
void PostProcessorGaussBlur::postProcess( ACG::GLState* _glstate, const std::vector<const PostProcessorInput*>& _input, const PostProcessorOutput& _output )
{
glBindFramebuffer(GL_FRAMEBUFFER, _output.fbo_);
glDrawBuffer(_output.drawBuffer_);
glDepthMask(1);
glColorMask(1,1,1,1);
blurGauss_.resizeInput(_input[0]->width, _input[0]->height);
blurGauss_.execute(_input[0]->colorTex_, 0, 0, 0);
}
QAction* PostProcessorGaussBlur::optionsAction()
{
QAction * action = new QAction("Gaussian Blur Options" , this );
connect(action,SIGNAL(triggered( bool )),this,SLOT(optionDialog( bool )));
return action;
}
void PostProcessorGaussBlur::optionDialog( bool )
{
//generate widget
QDialog* optionsDlg = new QDialog();
QVBoxLayout* layout = new QVBoxLayout();
layout->setAlignment(Qt::AlignTop);
QColor curColor;
curColor.setRgbF(0.3f, 0.2f, 0.7f);
QLabel* label = new QLabel(tr("Radius [1, 32]:"));
layout->addWidget(label);
QSlider* radiusSlider = new QSlider(Qt::Horizontal);
radiusSlider->setRange(1, 32);
radiusSlider->setValue(8);
radiusSlider->setTracking(true);
layout->addWidget(radiusSlider);
label = new QLabel(tr("Sigma [0.1, 20.0]:"));
layout->addWidget(label);
QSlider* sigmaSlider = new QSlider(Qt::Horizontal);
sigmaSlider->setRange(1, 200);
sigmaSlider->setValue(10);
sigmaSlider->setTracking(true);
layout->addWidget(sigmaSlider);
optionsDlg->setLayout(layout);
connect(radiusSlider, SIGNAL(sliderMoved(int)), this, SLOT(radiusChanged(int)));
connect(sigmaSlider, SIGNAL(sliderMoved(int)), this, SLOT(sigmaChanged(int)));
// connect(outlineColorBtn, SIGNAL(colorChanged(QColor)), this, SLOT(outlineColorChanged(QColor)));
optionsDlg->show();
}
void PostProcessorGaussBlur::radiusChanged( int _radius )
{
blurGauss_.setKernel(_radius, blurGauss_.sigma());
}
void PostProcessorGaussBlur::sigmaChanged( int _val )
{
float sigma = float(_val) * 0.1f;
blurGauss_.setKernel(blurGauss_.radius(), sigma);
}
#if QT_VERSION < 0x050000
Q_EXPORT_PLUGIN2( postprocessorgaussblurplugin , PostProcessorGaussBlur );
#endif
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 17080 $ *
* $LastChangedBy: moeller $ *
* $Date: 2013-07-19 12:58:31 +0200 (Fri, 19 Jul 2013) $ *
* *
\*===========================================================================*/
#include <QObject>
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/PostProcessorInterface.hh>
#include <ACG/GL/globjects.hh>
#include <ACG/ShaderUtils/GLSLShader.hh>
#include <ACG/GL/FBO.hh>
#include <vector>
#include <ACG/GL/FilterKernels.hh>
class PostProcessorGaussBlur : public QObject, BaseInterface, PostProcessorInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
Q_INTERFACES(PostProcessorInterface)
#if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-PostProcessorGaussBlur")
#endif
public:
PostProcessorGaussBlur();
~PostProcessorGaussBlur();
public :
QString name() { return (QString("Gaussian Blur Postprocessor Plugin")); };
QString description( ) { return (QString(tr("Separable gaussian blur"))); };
public slots:
QString version() { return QString("1.0"); };
QAction* optionsAction();
private slots:
void postProcess(ACG::GLState* _glstate, const std::vector<const PostProcessorInput*>& _input, const PostProcessorOutput& _output);
QString postProcessorName() {return QString("Gaussian Blur");}
QString checkOpenGL();
void optionDialog(bool);
void radiusChanged(int);
void sigmaChanged(int);
private:
ACG::GaussianBlurFilter blurGauss_;
};
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 17080 $ *
* $LastChangedBy: moeller $ *
* $Date: 2013-07-19 12:58:31 +0200 (Fri, 19 Jul 2013) $ *
* *
\*===========================================================================*/
#include <ACG/GL/acg_glew.hh>
#include "PostProcessorPoissonBlur.hh"
#include <ACG/GL/ScreenQuad.hh>
#include <ACG/GL/ShaderCache.hh>
#include <ACG/GL/GLFormatInfo.hh>
#include <QDialog>
#include <QLabel>
#include <QSlider>
#include <QVBoxLayout>
#include <QPushButton>
PostProcessorPoissonBlur::PostProcessorPoissonBlur()
: blur_(new ACG::PoissonBlurFilter(1.0f, 0.5f)), radius_(1.0f), minDist_(0.5f)
{
}
PostProcessorPoissonBlur::~PostProcessorPoissonBlur()
{
delete blur_;
}
QString PostProcessorPoissonBlur::checkOpenGL()
{
if (!ACG::openGLVersion(3,0))
return QString("SSAO plugin requires OpenGL 3.0!");
return QString("");
}
void PostProcessorPoissonBlur::postProcess( ACG::GLState* _glstate, const std::vector<const PostProcessorInput*>& _input, const PostProcessorOutput& _output )
{
glBindFramebuffer(GL_FRAMEBUFFER, _output.fbo_);
glDrawBuffer(_output.drawBuffer_);
glDepthMask(1);
glColorMask(1,1,1,1);
float scale = 1.0f / std::min(_input[0]->width, _input[0]->height);
blur_->execute(_input[0]->colorTex_, scale);
}
QAction* PostProcessorPoissonBlur::optionsAction()
{
QAction * action = new QAction("Gaussian Blur Options" , this );
connect(action,SIGNAL(triggered( bool )),this,SLOT(optionDialog( bool )));
return action;
}
void PostProcessorPoissonBlur::optionDialog( bool )
{
//generate widget
QDialog* optionsDlg = new QDialog();
QVBoxLayout* layout = new QVBoxLayout();
layout->setAlignment(Qt::AlignTop);
QColor curColor;
curColor.setRgbF(0.3f, 0.2f, 0.7f);
QLabel* label = new QLabel(tr("Radius [0, 32]:"));
layout->addWidget(label);
QSlider* radiusSlider = new