44 #include <ACG/GL/acg_glew.hh>
46 #include "PostProcessorBilateralBlur.hh"
48 #include <ACG/GL/ScreenQuad.hh>
49 #include <ACG/GL/ShaderCache.hh>
50 #include <ACG/GL/GLFormatInfo.hh>
56 #include <QVBoxLayout>
57 #include <ACG/QtWidgets/QtColorChooserButton.hh>
61 PostProcessorBilateralBlur::PostProcessorBilateralBlur()
62 : blur_(32, 32, 4, 2.0f, 2.0f, GL_RGBA)
67 PostProcessorBilateralBlur::~PostProcessorBilateralBlur()
71 QString PostProcessorBilateralBlur::checkOpenGL()
74 return QString(
"Bilateral blur plugin requires OpenGL 3.0!");
80 void PostProcessorBilateralBlur::postProcess(
ACG::GLState* _glstate,
const std::vector<const PostProcessorInput*>& _input,
const PostProcessorOutput& _output )
82 glBindFramebuffer(GL_FRAMEBUFFER, _output.fbo_);
83 glDrawBuffer(_output.drawBuffer_);
90 blur_.resizeInput(_input[0]->width, _input[0]->height);
93 blur_.setParams(_glstate->
projection(), _input[0]->depthTex_);
96 blur_.execute(_input[0]->colorTex_, 0, 0, 0);
101 QAction * action =
new QAction(
"Gaussian Blur Options" ,
this );
103 connect(action,SIGNAL(triggered(
bool )),
this,SLOT(optionDialog(
bool )));
108 void PostProcessorBilateralBlur::optionDialog(
bool )
111 QDialog* optionsDlg =
new QDialog();
112 QVBoxLayout* layout =
new QVBoxLayout();
113 layout->setAlignment(Qt::AlignTop);
116 curColor.setRgbF(0.3f, 0.2f, 0.7f);
118 QLabel* label =
new QLabel(tr(
"Radius [1, 32]:"));
119 layout->addWidget(label);
121 QSlider* radiusSlider =
new QSlider(Qt::Horizontal);
122 radiusSlider->setRange(1, 32);
123 radiusSlider->setValue(8);
124 radiusSlider->setTracking(
true);
125 layout->addWidget(radiusSlider);
128 label =
new QLabel(tr(
"spatial sigma [0.1, 20.0]:"));
129 layout->addWidget(label);
131 QSlider* sigmaSlider =
new QSlider(Qt::Horizontal);
132 sigmaSlider->setRange(1, 200);
133 sigmaSlider->setValue(10);
134 sigmaSlider->setTracking(
true);
135 layout->addWidget(sigmaSlider);
138 label =
new QLabel(tr(
"linear depth sigma [0.1, 20.0]:"));
139 layout->addWidget(label);
141 QSlider* sigmaRSlider =
new QSlider(Qt::Horizontal);
142 sigmaRSlider->setRange(1, 200);
143 sigmaRSlider->setValue(10);
144 sigmaRSlider->setTracking(
true);
145 layout->addWidget(sigmaRSlider);
148 optionsDlg->setLayout(layout);
151 connect(radiusSlider, SIGNAL(sliderMoved(
int)),
this, SLOT(radiusChanged(
int)));
152 connect(sigmaSlider, SIGNAL(sliderMoved(
int)),
this, SLOT(sigmaSChanged(
int)));
153 connect(sigmaRSlider, SIGNAL(sliderMoved(
int)),
this, SLOT(sigmaRChanged(
int)));
160 void PostProcessorBilateralBlur::radiusChanged(
int _radius )
163 blur_.setKernel(_radius, sigma[0], sigma[1]);
166 void PostProcessorBilateralBlur::sigmaSChanged(
int _val )
169 sigma[0] = float(_val) * 0.1f;
170 blur_.setKernel(blur_.
radius(), sigma[0], sigma[1]);
174 void PostProcessorBilateralBlur::sigmaRChanged(
int _val )
177 sigma[1] = float(_val) * 0.1f;
178 blur_.setKernel(blur_.
radius(), sigma[0], sigma[1]);
182 #if QT_VERSION < 0x050000
int radius() const
radius
const GLMatrixd & projection() const
get projection matrix
QAction * optionsAction()
Return options menu.
const ACG::Vec2f & sigma() const
blur (sigmaS, sigmaR)
bool openGLVersion(const int _major, const int _minor)