git-svn-id: svn://db.shs.com.ru/libs@69 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
Binary file not shown.
@@ -104,6 +104,22 @@ void GLObjectBase::setView(QGLView * v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLObjectBase::clearChildren(bool deleteAll) {
|
||||||
|
foreach (GLObjectBase * i, children_) {
|
||||||
|
i->setView(0);
|
||||||
|
i->parent_ = 0;
|
||||||
|
if (deleteAll) {
|
||||||
|
i->clearChildren(true);
|
||||||
|
delete i;
|
||||||
|
} else {
|
||||||
|
i->buildTransform();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
children_.clear();
|
||||||
|
if (view_) view_->collectLights();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<GLObjectBase * > GLObjectBase::children(bool all_) {
|
QList<GLObjectBase * > GLObjectBase::children(bool all_) {
|
||||||
if (!all_) return children_;
|
if (!all_) return children_;
|
||||||
QList<GLObjectBase * > cl;
|
QList<GLObjectBase * > cl;
|
||||||
@@ -187,7 +203,7 @@ void GLObjectBase::localTransform(QMatrix4x4 & m) {
|
|||||||
|
|
||||||
|
|
||||||
void GLObjectBase::checkPass() {
|
void GLObjectBase::checkPass() {
|
||||||
if (material_.reflectivity > 0.f || material_.color_diffuse.alphaF() * (1.f - material_.transparency) < 1.f) pass_ = Transparent;
|
if (material_.color_diffuse.alphaF() * (1.f - material_.transparency) < 1.f) pass_ = Transparent;
|
||||||
else pass_ = Solid;
|
else pass_ = Solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public:
|
|||||||
void addChild(GLObjectBase * o) {if (o == this) return; if (o->parent_ != 0) o->parent_->children_.removeAll(o); children_ << o; o->parent_ = this; o->buildTransform(); if (view_ != 0) view_->collectLights();}
|
void addChild(GLObjectBase * o) {if (o == this) return; if (o->parent_ != 0) o->parent_->children_.removeAll(o); children_ << o; o->parent_ = this; o->buildTransform(); if (view_ != 0) view_->collectLights();}
|
||||||
void removeChild(GLObjectBase * o) {if (o == this) return; children_.removeAll(o); o->parent_ = 0; o->buildTransform(); if (view_ != 0) view_->collectLights();}
|
void removeChild(GLObjectBase * o) {if (o == this) return; children_.removeAll(o); o->parent_ = 0; o->buildTransform(); if (view_ != 0) view_->collectLights();}
|
||||||
void removeChild(int index) {children_[index]->parent_ = 0; children_[index]->buildTransform(); children_.removeAt(index); if (view_ != 0) view_->collectLights();}
|
void removeChild(int index) {children_[index]->parent_ = 0; children_[index]->buildTransform(); children_.removeAt(index); if (view_ != 0) view_->collectLights();}
|
||||||
void clearChildren(bool deleteAll = false) {foreach (GLObjectBase * i, children_) {if (deleteAll) {i->clearChildren(true); delete i;} else {i->parent_ = 0; i->buildTransform();}} children_.clear(); if (view_ != 0) view_->collectLights();}
|
void clearChildren(bool deleteAll = false);
|
||||||
int childCount() const {return children_.size();}
|
int childCount() const {return children_.size();}
|
||||||
GLObjectBase * child(int index) {if (index < 0 || index >= children_.size()) return 0; return children_[index];}
|
GLObjectBase * child(int index) {if (index < 0 || index >= children_.size()) return 0; return children_[index];}
|
||||||
GLObjectBase * child(const QString & name) {foreach (GLObjectBase * i, children_) if (i->name_ == name) return i; return 0;}
|
GLObjectBase * child(const QString & name) {foreach (GLObjectBase * i, children_) if (i->name_ == name) return i; return 0;}
|
||||||
|
|||||||
@@ -67,17 +67,19 @@ MainWindow::MainWindow(QWidget * parent): QMainWindow(parent), Ui::MainWindow()
|
|||||||
groupEyeAccomodation->setChecked(view->isFeatureEnabled(QGLView::qglEyeAccomodationEnabled));
|
groupEyeAccomodation->setChecked(view->isFeatureEnabled(QGLView::qglEyeAccomodationEnabled));
|
||||||
groupBloom->setChecked(view->isFeatureEnabled(QGLView::qglBloomEnabled));
|
groupBloom->setChecked(view->isFeatureEnabled(QGLView::qglBloomEnabled));
|
||||||
groupMotionBlur->setChecked(view->isFeatureEnabled(QGLView::qglMotionBlurEnabled));
|
groupMotionBlur->setChecked(view->isFeatureEnabled(QGLView::qglMotionBlurEnabled));
|
||||||
groupReflections->setChecked(view->isFeatureEnabled(QGLView::qglDynamicReflectionsEnabled));
|
groupReflections->setChecked(view->isFeatureEnabled(QGLView::qglReflectionsEnabled));
|
||||||
checkSoftShadows->setChecked(view->isFeatureEnabled(QGLView::qglShadowsSoftEnabled));
|
checkSoftShadows->setChecked(view->isFeatureEnabled(QGLView::qglShadowsSoftEnabled));
|
||||||
|
groupSSAO->setChecked(view->isFeatureEnabled(QGLView::qglSSAOEnabled));
|
||||||
spinAccom->setValue(view->feature(QGLView::qglEyeAccomodationTime).toDouble());
|
spinAccom->setValue(view->feature(QGLView::qglEyeAccomodationTime).toDouble());
|
||||||
spinAccomMS->setValue(view->feature(QGLView::qglEyeAccomodationMaxSpeed).toDouble());
|
spinAccomMS->setValue(view->feature(QGLView::qglEyeAccomodationMaxSpeed).toDouble());
|
||||||
spinCubemapSize->setValue(view->feature(QGLView::qglDynamicReflectionsMapSize).toInt());
|
checkReflectionsBlur->setChecked(view->isFeatureEnabled(QGLView::qglReflectionsBlur));
|
||||||
spinShadowmapSize->setValue(view->feature(QGLView::qglShadowsMapSize).toInt());
|
spinShadowmapSize->setValue(view->feature(QGLView::qglShadowsMapSize).toInt());
|
||||||
spinMotionBlurFactor->setValue(view->feature(QGLView::qglMotionBlurFactor).toDouble());
|
spinMotionBlurFactor->setValue(view->feature(QGLView::qglMotionBlurFactor).toDouble());
|
||||||
spinMotionBlurSteps->setValue(view->feature(QGLView::qglMotionBlurSteps).toInt());
|
spinMotionBlurSteps->setValue(view->feature(QGLView::qglMotionBlurSteps).toInt());
|
||||||
spinBloomFactor->setValue(view->feature(QGLView::qglBloomFactor).toDouble());
|
spinBloomFactor->setValue(view->feature(QGLView::qglBloomFactor).toDouble());
|
||||||
spinBloomRadius->setValue(view->feature(QGLView::qglBloomRadius).toInt());
|
spinBloomRadius->setValue(view->feature(QGLView::qglBloomRadius).toInt());
|
||||||
spinBloomThreshold->setValue(view->feature(QGLView::qglBloomThreshold).toDouble());
|
spinBloomThreshold->setValue(view->feature(QGLView::qglBloomThreshold).toDouble());
|
||||||
|
spinSSAORadius->setValue(view->feature(QGLView::qglSSAORadius).toInt());
|
||||||
|
|
||||||
axis = new GLObjectBase();
|
axis = new GLObjectBase();
|
||||||
GLObjectBase * obj;
|
GLObjectBase * obj;
|
||||||
@@ -222,6 +224,7 @@ void MainWindow::on_actionReset_triggered() {
|
|||||||
view->removeObject(axis, false);
|
view->removeObject(axis, false);
|
||||||
view->clearObjects(true);
|
view->clearObjects(true);
|
||||||
view->addObject(axis);
|
view->addObject(axis);
|
||||||
|
objectsTreeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -87,17 +87,19 @@ private slots:
|
|||||||
void on_groupEyeAccomodation_clicked(bool val) {view->setFeature(QGLView::qglEyeAccomodationEnabled, val);}
|
void on_groupEyeAccomodation_clicked(bool val) {view->setFeature(QGLView::qglEyeAccomodationEnabled, val);}
|
||||||
void on_groupBloom_clicked(bool val) {view->setFeature(QGLView::qglBloomEnabled, val);}
|
void on_groupBloom_clicked(bool val) {view->setFeature(QGLView::qglBloomEnabled, val);}
|
||||||
void on_groupMotionBlur_clicked(bool val) {view->setFeature(QGLView::qglMotionBlurEnabled, val);}
|
void on_groupMotionBlur_clicked(bool val) {view->setFeature(QGLView::qglMotionBlurEnabled, val);}
|
||||||
void on_groupReflections_clicked(bool val) {view->setFeature(QGLView::qglDynamicReflectionsEnabled, val);}
|
void on_groupReflections_clicked(bool val) {view->setFeature(QGLView::qglReflectionsEnabled, val);}
|
||||||
void on_checkSoftShadows_clicked(bool val) {view->setFeature(QGLView::qglShadowsSoftEnabled, val);}
|
void on_checkSoftShadows_clicked(bool val) {view->setFeature(QGLView::qglShadowsSoftEnabled, val);}
|
||||||
|
void on_groupSSAO_clicked(bool val) {view->setFeature(QGLView::qglSSAOEnabled, val);}
|
||||||
void on_spinAccom_valueChanged(double val) {view->setFeature(QGLView::qglEyeAccomodationTime, val);}
|
void on_spinAccom_valueChanged(double val) {view->setFeature(QGLView::qglEyeAccomodationTime, val);}
|
||||||
void on_spinAccomMS_valueChanged(double val) {view->setFeature(QGLView::qglEyeAccomodationMaxSpeed, val);}
|
void on_spinAccomMS_valueChanged(double val) {view->setFeature(QGLView::qglEyeAccomodationMaxSpeed, val);}
|
||||||
void on_spinCubemapSize_valueChanged(double val) {view->setFeature(QGLView::qglDynamicReflectionsMapSize, val);}
|
void on_checkReflectionsBlur_clicked(bool val) {view->setFeature(QGLView::qglReflectionsBlur, val);}
|
||||||
void on_spinShadowmapSize_valueChanged(double val) {view->setFeature(QGLView::qglShadowsMapSize, val);}
|
void on_spinShadowmapSize_valueChanged(double val) {view->setFeature(QGLView::qglShadowsMapSize, val);}
|
||||||
void on_spinMotionBlurFactor_valueChanged(double val) {view->setFeature(QGLView::qglMotionBlurFactor, val);}
|
void on_spinMotionBlurFactor_valueChanged(double val) {view->setFeature(QGLView::qglMotionBlurFactor, val);}
|
||||||
void on_spinMotionBlurSteps_valueChanged(int val) {view->setFeature(QGLView::qglMotionBlurSteps, val);}
|
void on_spinMotionBlurSteps_valueChanged(int val) {view->setFeature(QGLView::qglMotionBlurSteps, val);}
|
||||||
void on_spinBloomFactor_valueChanged(double val) {view->setFeature(QGLView::qglBloomFactor, val);}
|
void on_spinBloomFactor_valueChanged(double val) {view->setFeature(QGLView::qglBloomFactor, val);}
|
||||||
void on_spinBloomRadius_valueChanged(int val) {view->setFeature(QGLView::qglBloomRadius, val);}
|
void on_spinBloomRadius_valueChanged(int val) {view->setFeature(QGLView::qglBloomRadius, val);}
|
||||||
void on_spinBloomThreshold_valueChanged(double val) {view->setFeature(QGLView::qglBloomThreshold, val);}
|
void on_spinBloomThreshold_valueChanged(double val) {view->setFeature(QGLView::qglBloomThreshold, val);}
|
||||||
|
void on_spinSSAORadius_valueChanged(int val) {view->setFeature(QGLView::qglSSAORadius, val);}
|
||||||
|
|
||||||
void on_actionExit_triggered() {close();}
|
void on_actionExit_triggered() {close();}
|
||||||
void on_actionReset_triggered();
|
void on_actionReset_triggered();
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidget_2">
|
<widget class="QTabWidget" name="tabWidget_2">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab_5">
|
<widget class="QWidget" name="tab_5">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@@ -721,35 +721,60 @@
|
|||||||
<property name="labelAlignment">
|
<property name="labelAlignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_15">
|
<widget class="QCheckBox" name="checkReflectionsBlur">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Cubemap size</string>
|
<string>Blur</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupSSAO">
|
||||||
|
<property name="title">
|
||||||
|
<string>SSAO</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout_7">
|
||||||
|
<property name="fieldGrowthPolicy">
|
||||||
|
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||||
|
</property>
|
||||||
|
<property name="labelAlignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_9">
|
||||||
|
<property name="text">
|
||||||
|
<string>Time</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="SpinSlider" name="spinCubemapSize">
|
<widget class="SpinSlider" name="spinSSAORadius">
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<double>16.000000000000000</double>
|
<double>0.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<double>2048.000000000000000</double>
|
<double>16.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="value">
|
<property name="value">
|
||||||
<double>512.000000000000000</double>
|
<double>5.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="decimals">
|
<property name="decimals">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="singleStep">
|
<property name="singleStep">
|
||||||
<double>16.000000000000000</double>
|
<double>1.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="pageStep">
|
<property name="pageStep">
|
||||||
<double>512.000000000000000</double>
|
<double>4.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="squareScale">
|
<property name="squareScale">
|
||||||
<bool>true</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -73,8 +73,10 @@ QGLView::QGLView(QWidget * parent): QGraphicsView(parent), fbo_selection(3) {
|
|||||||
setFeature(qglShadowsEnabled, false);
|
setFeature(qglShadowsEnabled, false);
|
||||||
setFeature(qglShadowsMapSize, 512);
|
setFeature(qglShadowsMapSize, 512);
|
||||||
setFeature(qglShadowsSoftEnabled, true);
|
setFeature(qglShadowsSoftEnabled, true);
|
||||||
setFeature(qglDynamicReflectionsEnabled, false);
|
setFeature(qglReflectionsEnabled, false);
|
||||||
setFeature(qglDynamicReflectionsMapSize, 512);
|
setFeature(qglReflectionsBlur, true);
|
||||||
|
setFeature(qglSSAOEnabled, false);
|
||||||
|
setFeature(qglSSAORadius, 5);
|
||||||
mouse_first = mouseSelect_ = hoverHalo_ = selectionHalo_ = true;
|
mouse_first = mouseSelect_ = hoverHalo_ = selectionHalo_ = true;
|
||||||
fogEnabled_ = is_init = grabMouse_ = mouseRotate_ = mouseThis_ = shaders_bind = changed_ = false;
|
fogEnabled_ = is_init = grabMouse_ = mouseRotate_ = mouseThis_ = shaders_bind = changed_ = false;
|
||||||
rmode = GLObjectBase::Fill;
|
rmode = GLObjectBase::Fill;
|
||||||
|
|||||||
@@ -97,8 +97,10 @@ public:
|
|||||||
qglShadowsEnabled,
|
qglShadowsEnabled,
|
||||||
qglShadowsMapSize,
|
qglShadowsMapSize,
|
||||||
qglShadowsSoftEnabled,
|
qglShadowsSoftEnabled,
|
||||||
qglDynamicReflectionsEnabled,
|
qglReflectionsEnabled,
|
||||||
qglDynamicReflectionsMapSize
|
qglReflectionsBlur,
|
||||||
|
qglSSAOEnabled,
|
||||||
|
qglSSAORadius
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_ENUMS (FogMode)
|
Q_ENUMS (FogMode)
|
||||||
@@ -157,7 +159,7 @@ public:
|
|||||||
int objectsCount(bool all = false) {if (!all) return objects_.childCount(); int cnt = 0; objectsCountInternal(&cnt, &objects_); return cnt;}
|
int objectsCount(bool all = false) {if (!all) return objects_.childCount(); int cnt = 0; objectsCountInternal(&cnt, &objects_); return cnt;}
|
||||||
void removeObject(GLObjectBase * o, bool inChildren = true) {if (inChildren) removeObjectInternal(o, &objects_); else objects_.removeChild(o);}
|
void removeObject(GLObjectBase * o, bool inChildren = true) {if (inChildren) removeObjectInternal(o, &objects_); else objects_.removeChild(o);}
|
||||||
void removeObject(GLObjectBase & o, bool inChildren = true) {removeObject(&o, inChildren);}
|
void removeObject(GLObjectBase & o, bool inChildren = true) {removeObject(&o, inChildren);}
|
||||||
void clearObjects(bool deleteAll = false) {objects_.clearChildren(deleteAll); addObject(camera()); sel_obj = hov_obj = 0;}
|
void clearObjects(bool deleteAll = false) {removeObject(camera_); objects_.clearChildren(deleteAll); addObject(camera()); sel_obj = hov_obj = 0;}
|
||||||
QList<GLObjectBase * > objects(bool all = false) {return objects_.children(all);}
|
QList<GLObjectBase * > objects(bool all = false) {return objects_.children(all);}
|
||||||
|
|
||||||
int lightsCount() const {return lights_.size();}
|
int lightsCount() const {return lights_.size();}
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ fbo_g(5, true, GL_RGBA16F), fbo_out(3, false, GL_RGBA16F), fbo_hsmall(1, false,
|
|||||||
<< ShaderPair("shadow", &shader_shadow)
|
<< ShaderPair("shadow", &shader_shadow)
|
||||||
<< ShaderPair("ssr", &shader_ssr)
|
<< ShaderPair("ssr", &shader_ssr)
|
||||||
<< ShaderPair("ssr_blur", &shader_ssr_blur)
|
<< ShaderPair("ssr_blur", &shader_ssr_blur)
|
||||||
<< ShaderPair("ssr_merge", &shader_ssr_merge);
|
<< ShaderPair("ssr_merge", &shader_ssr_merge)
|
||||||
|
<< ShaderPair("ssao_blur", &shader_ssao_blur)
|
||||||
|
<< ShaderPair("ssao_merge", &shader_ssao_merge);
|
||||||
for (int i = 0; i < shaders.size(); ++i)
|
for (int i = 0; i < shaders.size(); ++i)
|
||||||
*(shaders[i].second) = 0;
|
*(shaders[i].second) = 0;
|
||||||
lights_per_pass = 8;
|
lights_per_pass = 8;
|
||||||
@@ -197,7 +199,66 @@ void RendererDeferredShading::renderScene() {
|
|||||||
glActiveTextureChannel(0);
|
glActiveTextureChannel(0);
|
||||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(ri));
|
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(ri));
|
||||||
|
|
||||||
if (view.isFeatureEnabled(QGLView::qglDynamicReflectionsEnabled)) {
|
if (view.isFeatureEnabled(QGLView::qglSSAOEnabled)) {
|
||||||
|
fbo_out.setWriteBuffer(2);
|
||||||
|
fbo_out.setReadBuffer(ri);
|
||||||
|
glBlitFramebuffer(0, 0, fbo_out.width(), fbo_out.height(), 0, 0, fbo_out.width(), fbo_out.height(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||||
|
glActiveTextureChannel(1);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(2));
|
||||||
|
glActiveTextureChannel(2);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, fbo_g.colorTexture(1));
|
||||||
|
glActiveTextureChannel(0);
|
||||||
|
//glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(ri));
|
||||||
|
//glActiveTextureChannel(1);
|
||||||
|
//glBindTexture(GL_TEXTURE_2D, fbo_g.colorTexture(0));
|
||||||
|
int lri = ri, lwi = wi;//, lms = ri;
|
||||||
|
shader_ssao_blur->bind();
|
||||||
|
shader_ssao_blur->setUniformValue("qgl_ModelViewProjectionMatrix", QMatrix4x4());
|
||||||
|
shader_ssao_blur->setUniformValue("dt", QVector2D(1. / fbo_out.width(), 1. / fbo_out.height()));
|
||||||
|
shader_ssao_blur->setUniformValue("t0", 0);
|
||||||
|
shader_ssao_blur->setUniformValue("ts", 1);
|
||||||
|
shader_ssao_blur->setUniformValue("tg1", 2);
|
||||||
|
int passes = view.feature(QGLView::qglSSAORadius).toInt();
|
||||||
|
int crad = 1;
|
||||||
|
for (int p = 0; p < passes; ++p) {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(lri));
|
||||||
|
fbo_out.setWriteBuffer(lwi);
|
||||||
|
shader_ssao_blur->setUniformValue("radius", GLfloat(crad));
|
||||||
|
glDrawQuad(shader_ssao_blur);
|
||||||
|
piSwap<int>(lwi, lri);
|
||||||
|
crad *= 2;
|
||||||
|
}
|
||||||
|
//qDebug() << wi << ri << lms;
|
||||||
|
/*wi = lri;
|
||||||
|
ri = 1 - lms;*/
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(lri));
|
||||||
|
glActiveTextureChannel(1);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(2));
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
glActiveTextureChannel(2);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, fbo_g.colorTexture(1));
|
||||||
|
shader_ssao_merge->bind();
|
||||||
|
shader_ssao_merge->setUniformValue("qgl_ModelViewProjectionMatrix", QMatrix4x4());
|
||||||
|
shader_ssao_merge->setUniformValue("z_far", GLfloat(view.depthEnd()));
|
||||||
|
shader_ssao_merge->setUniformValue("z_near", GLfloat(view.depthStart()));
|
||||||
|
shader_ssao_merge->setUniformValue("mat_proj", mproj);
|
||||||
|
shader_ssao_merge->setUniformValue("t0", 0);
|
||||||
|
shader_ssao_merge->setUniformValue("ts", 1);
|
||||||
|
shader_ssao_merge->setUniformValue("tg1", 2);
|
||||||
|
fbo_out.setWriteBuffer(lwi);
|
||||||
|
glDrawQuad(shader_ssao_merge, corner_dirs);
|
||||||
|
wi = lri;
|
||||||
|
ri = lwi;
|
||||||
|
//piSwap<int>(wi, ri);
|
||||||
|
|
||||||
|
glActiveTextureChannel(0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(ri));
|
||||||
|
//piSwap<int>(wi, ri);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view.isFeatureEnabled(QGLView::qglReflectionsEnabled)) {
|
||||||
fbo_out.setWriteBuffer(2);
|
fbo_out.setWriteBuffer(2);
|
||||||
glActiveTextureChannel(0);
|
glActiveTextureChannel(0);
|
||||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(ri));
|
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(ri));
|
||||||
@@ -216,38 +277,40 @@ void RendererDeferredShading::renderScene() {
|
|||||||
shader_ssr->setUniformValue("t0", 1);
|
shader_ssr->setUniformValue("t0", 1);
|
||||||
shader_ssr->setUniformValue("t1", 2);
|
shader_ssr->setUniformValue("t1", 2);
|
||||||
shader_ssr->setUniformValue("ts", 0);
|
shader_ssr->setUniformValue("ts", 0);
|
||||||
//shader_ssr->setUniformValue("ts", 1);
|
|
||||||
shader_ssr->setUniformValue("factor", GLfloat(view.feature(QGLView::qglMotionBlurFactor).toDouble()));
|
|
||||||
shader_ssr->setUniformValue("steps", view.feature(QGLView::qglMotionBlurSteps).toInt());
|
|
||||||
glDrawQuad(shader_ssr, corner_dirs);
|
glDrawQuad(shader_ssr, corner_dirs);
|
||||||
|
|
||||||
shader_ssr_blur->bind();
|
|
||||||
shader_ssr_blur->setUniformValue("qgl_ModelViewProjectionMatrix", QMatrix4x4());
|
|
||||||
shader_ssr_blur->setUniformValue("dt", QVector2D(1. / fbo_out.width(), 1. / fbo_out.height()));
|
|
||||||
shader_ssr_blur->setUniformValue("t0", 0);
|
|
||||||
int passes = 4;
|
|
||||||
int crad = 1;
|
|
||||||
int lri = 2, lwi = wi, lms = ri;
|
|
||||||
glActiveTextureChannel(0);
|
glActiveTextureChannel(0);
|
||||||
for (int p = 0; p < passes; ++p) {
|
int lri = 2, lwi = wi, lms = ri;
|
||||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(lri));
|
if (view.isFeatureEnabled(QGLView::qglReflectionsBlur)) {
|
||||||
fbo_out.setWriteBuffer(lwi);
|
shader_ssr_blur->bind();
|
||||||
shader_ssr_blur->setUniformValue("radius", GLfloat(crad));
|
shader_ssr_blur->setUniformValue("qgl_ModelViewProjectionMatrix", QMatrix4x4());
|
||||||
glDrawQuad(shader_ssr_blur);
|
shader_ssr_blur->setUniformValue("dt", QVector2D(1. / fbo_out.width(), 1. / fbo_out.height()));
|
||||||
piSwap<int>(lwi, lri);
|
shader_ssr_blur->setUniformValue("t0", 0);
|
||||||
crad *= 2;
|
int passes = 5;
|
||||||
|
int crad = 1;
|
||||||
|
for (int p = 0; p < passes; ++p) {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(lri));
|
||||||
|
fbo_out.setWriteBuffer(lwi);
|
||||||
|
shader_ssr_blur->setUniformValue("radius", GLfloat(crad));
|
||||||
|
glDrawQuad(shader_ssr_blur);
|
||||||
|
piSwap<int>(lwi, lri);
|
||||||
|
crad *= 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
//qDebug() << wi << ri << lms;
|
||||||
wi = lri;
|
wi = lri;
|
||||||
ri = 1 - lms;
|
ri = 1 - lms;
|
||||||
qDebug() << wi << ri << lms;
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(wi));
|
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(wi));
|
||||||
glActiveTextureChannel(1);
|
glActiveTextureChannel(1);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, fbo_g.colorTexture(1));
|
||||||
|
glActiveTextureChannel(2);
|
||||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(lms));
|
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(lms));
|
||||||
shader_ssr_merge->bind();
|
shader_ssr_merge->bind();
|
||||||
shader_ssr_merge->setUniformValue("qgl_ModelViewProjectionMatrix", QMatrix4x4());
|
shader_ssr_merge->setUniformValue("qgl_ModelViewProjectionMatrix", QMatrix4x4());
|
||||||
shader_ssr_merge->setUniformValue("t0", 0);
|
shader_ssr_merge->setUniformValue("t0", 0);
|
||||||
shader_ssr_merge->setUniformValue("ts", 1);
|
shader_ssr_merge->setUniformValue("tg1", 1);
|
||||||
|
shader_ssr_merge->setUniformValue("ts", 2);
|
||||||
fbo_out.setWriteBuffer(ri);
|
fbo_out.setWriteBuffer(ri);
|
||||||
glDrawQuad(shader_ssr_blur);
|
glDrawQuad(shader_ssr_blur);
|
||||||
wi = ri;
|
wi = ri;
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ private:
|
|||||||
QGLShaderProgram * shader_fxaa, * shader_ds_0, * shader_ds_1, * shader_hdr, * shader_small;
|
QGLShaderProgram * shader_fxaa, * shader_ds_0, * shader_ds_1, * shader_hdr, * shader_small;
|
||||||
QGLShaderProgram * shader_bloom_0, * shader_bloom_1, * shader_motion_blur, * shader_fbo_add;
|
QGLShaderProgram * shader_bloom_0, * shader_bloom_1, * shader_motion_blur, * shader_fbo_add;
|
||||||
QGLShaderProgram * shader_shadow, * shader_ssr, * shader_ssr_blur, * shader_ssr_merge;
|
QGLShaderProgram * shader_shadow, * shader_ssr, * shader_ssr_blur, * shader_ssr_merge;
|
||||||
|
QGLShaderProgram * shader_ssao_blur, * shader_ssao_merge;
|
||||||
QVector<ShaderPair> shaders;
|
QVector<ShaderPair> shaders;
|
||||||
|
|
||||||
QMatrix4x4 prev_view, prev_proj;
|
QMatrix4x4 prev_view, prev_proj;
|
||||||
|
|||||||
@@ -20,30 +20,23 @@ void main(void) {
|
|||||||
vec4 dc = qgl_FragColor;
|
vec4 dc = qgl_FragColor;
|
||||||
vec2 tc = qgl_FragTexture.xy;
|
vec2 tc = qgl_FragTexture.xy;
|
||||||
float hei = dot(texture(qgl_Material.map_relief.map, tc).rgb, luma) * qgl_Material.map_relief.amount + qgl_Material.map_relief.offset;
|
float hei = dot(texture(qgl_Material.map_relief.map, tc).rgb, luma) * qgl_Material.map_relief.amount + qgl_Material.map_relief.offset;
|
||||||
//if (acc_fog) dc.xyz = mix(dc.rgb, gl_Fog.color.rgb, fogCoord);
|
|
||||||
|
|
||||||
vec3 n, dn, bn;
|
vec3 n, dn, bn;
|
||||||
dn = (texture(qgl_Material.map_normal.map, tc).rgb - vec3(0.5, 0.5, 1.)) * qgl_Material.map_normal.amount + qgl_Material.map_normal.offset;
|
dn = (texture(qgl_Material.map_normal.map, tc).rgb - vec3(0.5, 0.5, 1.)) * qgl_Material.map_normal.amount + qgl_Material.map_normal.offset;
|
||||||
//float tx = dn.x;
|
|
||||||
dn.y = -dn.y;
|
dn.y = -dn.y;
|
||||||
//dn.y = tx;
|
|
||||||
dn = TBN * dn;
|
dn = TBN * dn;
|
||||||
//dn = dn * mat3(qgl_ModelViewMatrix)*10;//*(mat3(qgl_NormalMatrix));
|
n = normalize(qgl_NormalMatrix * (normal + dn));
|
||||||
n = normalize(qgl_NormalMatrix * (normal + dn));//normalize(qgl_NormalMatrix * (normal - dn));
|
bn = normalize(qgl_NormalMatrix * binormal);
|
||||||
bn = normalize(qgl_NormalMatrix * binormal);//normalize(qgl_NormalMatrix * (normal - dn));
|
|
||||||
//n = dn;
|
//n = dn;
|
||||||
|
|
||||||
/*vec2 dpm = normalize(gl_FragCoord.xy * dt * 2. - vec2(1., 1.)), ntc;
|
|
||||||
ntc = gl_FragCoord.xy * dt * 2. - vec2(1., 1.) + dpm * hei;
|
|
||||||
dpm = gl_ModelViewProjectionMatrixInverse
|
|
||||||
dpm = dpm * gl_ModelViewProjectionMatrixInverse;
|
|
||||||
dpm += */
|
|
||||||
//tc += 1+et.xy * hei/10;// / et.z;
|
|
||||||
dc *= texture(qgl_Material.map_diffuse.map, tc) * qgl_Material.map_diffuse.amount + qgl_Material.map_diffuse.offset;
|
dc *= texture(qgl_Material.map_diffuse.map, tc) * qgl_Material.map_diffuse.amount + qgl_Material.map_diffuse.offset;
|
||||||
|
|
||||||
vec4 spec = texture(qgl_Material.map_specular.map, tc) * qgl_Material.map_specular.amount + qgl_Material.map_specular.offset;
|
vec4 spec = texture(qgl_Material.map_specular.map, tc) * qgl_Material.map_specular.amount + qgl_Material.map_specular.offset;
|
||||||
spec *= qgl_Material.color_specular;
|
spec *= qgl_Material.color_specular;
|
||||||
vec4 specularity = texture(qgl_Material.map_specularity.map, tc) * qgl_Material.map_specularity.amount + qgl_Material.map_specularity.offset;
|
float specularity = dot(texture(qgl_Material.map_specularity.map, tc).rgb, luma) * qgl_Material.map_specularity.amount + qgl_Material.map_specularity.offset;
|
||||||
|
specularity = clamp(specularity, 0.05, 0.99);
|
||||||
|
float reflectivity = qgl_Material.reflectivity;//dot(texture(qgl_Material.map_specularity.map, tc).rgb, luma) * qgl_Material.map_specularity.amount + qgl_Material.map_specularity.offset;
|
||||||
|
reflectivity = clamp(reflectivity, 0., 1.);
|
||||||
vec4 self = texture(qgl_Material.map_self_illumination.map, tc) * qgl_Material.map_self_illumination.amount + qgl_Material.map_self_illumination.offset;
|
vec4 self = texture(qgl_Material.map_self_illumination.map, tc) * qgl_Material.map_self_illumination.amount + qgl_Material.map_self_illumination.offset;
|
||||||
self *= qgl_Material.color_self_illumination;
|
self *= qgl_Material.color_self_illumination;
|
||||||
|
|
||||||
@@ -52,7 +45,7 @@ void main(void) {
|
|||||||
|
|
||||||
//gl_FragDepth = logz;
|
//gl_FragDepth = logz;
|
||||||
qgl_FragData[0] = vec4(dc.rgb, pos.w);
|
qgl_FragData[0] = vec4(dc.rgb, pos.w);
|
||||||
qgl_FragData[1] = vec4(n.xyz / 2. + vec3(0.5), specularity);
|
qgl_FragData[1] = vec4(n.xyz, specularity + round(reflectivity * 100));
|
||||||
qgl_FragData[2] = vec4(spec.rgb, hei);
|
qgl_FragData[2] = vec4(spec.rgb, hei);
|
||||||
qgl_FragData[3] = vec4(self.rgb, bn.x);
|
qgl_FragData[3] = vec4(self.rgb, bn.x);
|
||||||
qgl_FragData[4] = vec4(speed.xy, bn.yz);
|
qgl_FragData[4] = vec4(speed.xy, bn.yz);
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ void main(void) {
|
|||||||
v3 = texelFetch(t3, tc, 0),
|
v3 = texelFetch(t3, tc, 0),
|
||||||
v4 = texelFetch(t4, tc, 0);
|
v4 = texelFetch(t4, tc, 0);
|
||||||
vec2 sp = gl_FragCoord.xy * dt * 2 - vec2(1, 1);
|
vec2 sp = gl_FragCoord.xy * dt * 2 - vec2(1, 1);
|
||||||
vec3 dc = v0.rgb, n = v1.xyz * 2. - vec3(1.);
|
vec3 dc = v0.rgb, n = v1.xyz;
|
||||||
bn = normalize(vec3(v3.w, v4.zw));
|
bn = normalize(vec3(v3.w, v4.zw));
|
||||||
bn2 = normalize(cross(n, bn));
|
bn2 = normalize(cross(n, bn));
|
||||||
float height = v2.w;
|
float height = v2.w;
|
||||||
@@ -127,13 +127,15 @@ void main(void) {
|
|||||||
//pos.z = v0.w;
|
//pos.z = v0.w;
|
||||||
vec3 v = normalize(-pos.xyz);
|
vec3 v = normalize(-pos.xyz);
|
||||||
|
|
||||||
sh_pow = 1. / max((1. - v1.w), 0.0001);
|
float reflectivity = 0.;
|
||||||
sh_mul = max(1. - v1.w, 0.0001);
|
float specularity = modf(v1.w, reflectivity);
|
||||||
|
sh_pow = 1. / max((1. - specularity), 0.0001);
|
||||||
|
sh_mul = max(1. - specularity, 0.0001);
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
calcLight(i, n, v, v2);
|
calcLight(i, n, v, v2);
|
||||||
calcLight(0, n, v, v2);
|
calcLight(0, n, v, v2);
|
||||||
|
|
||||||
qgl_FragData[0].rgb = li * dc + si * v2.rgb + v3.rgb + texelFetch(t_pp, tc, 0).rgb;
|
qgl_FragData[0] = vec4(li * dc + si * v2.rgb + v3.rgb + texelFetch(t_pp, tc, 0).rgb, v0.w);
|
||||||
//qgl_FragData[0].rgb = vec3(abs((v0.w)/50));
|
//qgl_FragData[0].rgb = vec3(abs((v0.w)/50));
|
||||||
//qgl_FragData[0].rgb = li + vec3(texelFetch(t_pp, tc, 0).xyz);
|
//qgl_FragData[0].rgb = li + vec3(texelFetch(t_pp, tc, 0).xyz);
|
||||||
//shd = shd - shp.w;
|
//shd = shd - shp.w;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ void main(void) {
|
|||||||
for (int i = 0; i < steps; ++i) {
|
for (int i = 0; i < steps; ++i) {
|
||||||
ct += speed.xy * cdt;
|
ct += speed.xy * cdt;
|
||||||
float mul = 1. - abs(i - hsteps) * 2. / steps;
|
float mul = 1. - abs(i - hsteps) * 2. / steps;
|
||||||
scol += texture(t0, ct).rgb * mul;
|
scol += max(texture(t0, ct).rgb, vec3(0)) * mul;
|
||||||
sum += mul;
|
sum += mul;
|
||||||
}
|
}
|
||||||
scol /= sum;
|
scol /= sum;
|
||||||
|
|||||||
@@ -18,20 +18,22 @@ void main(void) {
|
|||||||
vec4 spos = pos;
|
vec4 spos = pos;
|
||||||
vec4 tpos;
|
vec4 tpos;
|
||||||
|
|
||||||
vec3 dc = v0.rgb, n = v1.xyz * 2. - vec3(1.);
|
vec3 dc = v0.rgb, n = v1.xyz;
|
||||||
vec3 vd = -normalize(vec3(-view_dir.xy, view_dir.z));
|
vec3 vd = -normalize(vec3(-view_dir.xy, view_dir.z));
|
||||||
vec3 rn = reflect(vd, n);
|
vec3 rn = reflect(vd, n);
|
||||||
//rn.z += 1.;
|
//rn.z += 1.;
|
||||||
float coeff = clamp(1.-(dot(vec3(0,0,1), n)), 0, 1), cz = v0.w;
|
float coeff = clamp(1. - (dot(vec3(0,0,1), n)), 0, 1), cz = v0.w;
|
||||||
coeff = coeff*coeff;
|
coeff = coeff*coeff;
|
||||||
coeff = coeff*coeff;
|
coeff = coeff*coeff;
|
||||||
|
float reflectivity = 0.;
|
||||||
|
float specularity = modf(v1.w, reflectivity);
|
||||||
|
|
||||||
rn.z = -rn.z;
|
rn.z = -rn.z;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
vec4 tv0;
|
vec4 tv0;
|
||||||
float l = z_far * 0.5;
|
float l = z_far * 0.5;
|
||||||
pos.xyz += rn * l;
|
pos.xyz += rn * l;
|
||||||
for (i = 0; i < 16; ++i) {
|
for (i = 0; i < 20; ++i) {
|
||||||
tpos = mat_proj * pos;
|
tpos = mat_proj * pos;
|
||||||
tsp = -(tpos.xy / tpos.w) / 2. + 0.5;
|
tsp = -(tpos.xy / tpos.w) / 2. + 0.5;
|
||||||
tv0 = texture(t0, tsp);
|
tv0 = texture(t0, tsp);
|
||||||
@@ -43,8 +45,11 @@ void main(void) {
|
|||||||
ess = clamp(ess, vec2(0, 0), vec2(0.2, 0.2));
|
ess = clamp(ess, vec2(0, 0), vec2(0.2, 0.2));
|
||||||
ess = smoothstep(vec2(0.2, 0.2), vec2(0, 0), ess);
|
ess = smoothstep(vec2(0.2, 0.2), vec2(0, 0), ess);
|
||||||
coeff *= min(ess.x, ess.y);
|
coeff *= min(ess.x, ess.y);
|
||||||
float blur = step(0., coeff) * length(pos.xyz - spos.xyz);
|
vec4 pr_pos = mat_proj * pos, pr_spos = mat_proj * spos;
|
||||||
vec3 rvs = texture(ts, tsp).rgb;
|
pr_pos.xyz /= pr_pos.w;
|
||||||
|
pr_spos.xyz /= pr_spos.w;
|
||||||
|
float blur = step(0., coeff) * length(pr_pos.xyz - pr_spos.xyz) * (1. - specularity);
|
||||||
|
vec3 rvs = max(texture(ts, tsp).rgb, vec3(0));
|
||||||
|
|
||||||
qgl_FragData[0] = vec4(rvs.rgb, coeff + clamp(round(blur * 10), 0, 1000));
|
qgl_FragData[0] = vec4(rvs.rgb, coeff / 1.1 + clamp(round(blur * 10), 0, 1000));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,11 @@ void main(void) {
|
|||||||
float r = float(radius);
|
float r = float(radius);
|
||||||
vec4 v0 = texture(t0, tc);
|
vec4 v0 = texture(t0, tc);
|
||||||
float rad;
|
float rad;
|
||||||
float coeff = modf(v0.a, rad);
|
float coeff = modf(v0.a, rad) * 1.1;
|
||||||
rad /= 10.;
|
rad /= 10.;
|
||||||
|
rad *= 2;
|
||||||
float o = radius * rad, o2 = radius * rad * 2;
|
float o = radius * rad, o2 = radius * rad * 2;
|
||||||
vec3 scol = (v0.rgb * 3. +
|
vec3 scol = (max(v0.rgb, vec3(0)) * 3. +
|
||||||
max(texture(t0, tc + dt * vec2( o, 0 )).rgb, vec3(0)) * 2. +
|
max(texture(t0, tc + dt * vec2( o, 0 )).rgb, vec3(0)) * 2. +
|
||||||
max(texture(t0, tc + dt * vec2( 0, o )).rgb, vec3(0)) * 2. +
|
max(texture(t0, tc + dt * vec2( 0, o )).rgb, vec3(0)) * 2. +
|
||||||
max(texture(t0, tc + dt * vec2( -o, 0 )).rgb, vec3(0)) * 2. +
|
max(texture(t0, tc + dt * vec2( -o, 0 )).rgb, vec3(0)) * 2. +
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
#version 150
|
#version 150
|
||||||
|
|
||||||
uniform sampler2D t0, ts;
|
uniform sampler2D t0, tg1, ts;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
ivec2 tc = ivec2(gl_FragCoord.xy);
|
ivec2 tc = ivec2(gl_FragCoord.xy);
|
||||||
vec4 v0 = texelFetch(t0, tc, 0), vs = texelFetch(ts, tc, 0);
|
vec4 v0 = texelFetch(t0, tc, 0), vg1 = texelFetch(tg1, tc, 0), vs = texelFetch(ts, tc, 0);
|
||||||
float rad;
|
float rad;
|
||||||
float coeff = modf(v0.a, rad);
|
float coeff = clamp(modf(v0.a, rad) * 1.1, 0., 1.);
|
||||||
qgl_FragData[0].rgb = mix(vs.rgb, v0.rgb, coeff);
|
float reflectivity = 0.;
|
||||||
//qgl_FragData[0].rgb = vec3(v0.rgb);
|
float specularity = modf(vg1.w, reflectivity);
|
||||||
|
reflectivity = clamp(reflectivity / 100., 0., 1.);
|
||||||
|
qgl_FragData[0].rgb = mix(vs.rgb, v0.rgb, coeff * reflectivity);
|
||||||
|
//qgl_FragData[0].rgb = vec3(vs.rgb*coeff * reflectivity);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user