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_) {
|
||||
if (!all_) return children_;
|
||||
QList<GLObjectBase * > cl;
|
||||
@@ -187,7 +203,7 @@ void GLObjectBase::localTransform(QMatrix4x4 & m) {
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 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 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();}
|
||||
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;}
|
||||
|
||||
@@ -67,17 +67,19 @@ MainWindow::MainWindow(QWidget * parent): QMainWindow(parent), Ui::MainWindow()
|
||||
groupEyeAccomodation->setChecked(view->isFeatureEnabled(QGLView::qglEyeAccomodationEnabled));
|
||||
groupBloom->setChecked(view->isFeatureEnabled(QGLView::qglBloomEnabled));
|
||||
groupMotionBlur->setChecked(view->isFeatureEnabled(QGLView::qglMotionBlurEnabled));
|
||||
groupReflections->setChecked(view->isFeatureEnabled(QGLView::qglDynamicReflectionsEnabled));
|
||||
groupReflections->setChecked(view->isFeatureEnabled(QGLView::qglReflectionsEnabled));
|
||||
checkSoftShadows->setChecked(view->isFeatureEnabled(QGLView::qglShadowsSoftEnabled));
|
||||
groupSSAO->setChecked(view->isFeatureEnabled(QGLView::qglSSAOEnabled));
|
||||
spinAccom->setValue(view->feature(QGLView::qglEyeAccomodationTime).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());
|
||||
spinMotionBlurFactor->setValue(view->feature(QGLView::qglMotionBlurFactor).toDouble());
|
||||
spinMotionBlurSteps->setValue(view->feature(QGLView::qglMotionBlurSteps).toInt());
|
||||
spinBloomFactor->setValue(view->feature(QGLView::qglBloomFactor).toDouble());
|
||||
spinBloomRadius->setValue(view->feature(QGLView::qglBloomRadius).toInt());
|
||||
spinBloomThreshold->setValue(view->feature(QGLView::qglBloomThreshold).toDouble());
|
||||
spinSSAORadius->setValue(view->feature(QGLView::qglSSAORadius).toInt());
|
||||
|
||||
axis = new GLObjectBase();
|
||||
GLObjectBase * obj;
|
||||
@@ -222,6 +224,7 @@ void MainWindow::on_actionReset_triggered() {
|
||||
view->removeObject(axis, false);
|
||||
view->clearObjects(true);
|
||||
view->addObject(axis);
|
||||
objectsTreeChanged();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -87,17 +87,19 @@ private slots:
|
||||
void on_groupEyeAccomodation_clicked(bool val) {view->setFeature(QGLView::qglEyeAccomodationEnabled, 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_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_groupSSAO_clicked(bool val) {view->setFeature(QGLView::qglSSAOEnabled, 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_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_spinMotionBlurFactor_valueChanged(double val) {view->setFeature(QGLView::qglMotionBlurFactor, 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_spinBloomRadius_valueChanged(int val) {view->setFeature(QGLView::qglBloomRadius, 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_actionReset_triggered();
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget_2">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_5">
|
||||
<attribute name="title">
|
||||
@@ -721,35 +721,60 @@
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="checkReflectionsBlur">
|
||||
<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>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="SpinSlider" name="spinCubemapSize">
|
||||
<widget class="SpinSlider" name="spinSSAORadius">
|
||||
<property name="minimum">
|
||||
<double>16.000000000000000</double>
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>2048.000000000000000</double>
|
||||
<double>16.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>512.000000000000000</double>
|
||||
<double>5.000000000000000</double>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>16.000000000000000</double>
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<double>512.000000000000000</double>
|
||||
<double>4.000000000000000</double>
|
||||
</property>
|
||||
<property name="squareScale">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -73,8 +73,10 @@ QGLView::QGLView(QWidget * parent): QGraphicsView(parent), fbo_selection(3) {
|
||||
setFeature(qglShadowsEnabled, false);
|
||||
setFeature(qglShadowsMapSize, 512);
|
||||
setFeature(qglShadowsSoftEnabled, true);
|
||||
setFeature(qglDynamicReflectionsEnabled, false);
|
||||
setFeature(qglDynamicReflectionsMapSize, 512);
|
||||
setFeature(qglReflectionsEnabled, false);
|
||||
setFeature(qglReflectionsBlur, true);
|
||||
setFeature(qglSSAOEnabled, false);
|
||||
setFeature(qglSSAORadius, 5);
|
||||
mouse_first = mouseSelect_ = hoverHalo_ = selectionHalo_ = true;
|
||||
fogEnabled_ = is_init = grabMouse_ = mouseRotate_ = mouseThis_ = shaders_bind = changed_ = false;
|
||||
rmode = GLObjectBase::Fill;
|
||||
|
||||
@@ -97,8 +97,10 @@ public:
|
||||
qglShadowsEnabled,
|
||||
qglShadowsMapSize,
|
||||
qglShadowsSoftEnabled,
|
||||
qglDynamicReflectionsEnabled,
|
||||
qglDynamicReflectionsMapSize
|
||||
qglReflectionsEnabled,
|
||||
qglReflectionsBlur,
|
||||
qglSSAOEnabled,
|
||||
qglSSAORadius
|
||||
};
|
||||
|
||||
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;}
|
||||
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 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);}
|
||||
|
||||
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("ssr", &shader_ssr)
|
||||
<< 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)
|
||||
*(shaders[i].second) = 0;
|
||||
lights_per_pass = 8;
|
||||
@@ -197,7 +199,66 @@ void RendererDeferredShading::renderScene() {
|
||||
glActiveTextureChannel(0);
|
||||
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);
|
||||
glActiveTextureChannel(0);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(ri));
|
||||
@@ -216,38 +277,40 @@ void RendererDeferredShading::renderScene() {
|
||||
shader_ssr->setUniformValue("t0", 1);
|
||||
shader_ssr->setUniformValue("t1", 2);
|
||||
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);
|
||||
|
||||
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);
|
||||
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;
|
||||
int lri = 2, lwi = wi, lms = ri;
|
||||
if (view.isFeatureEnabled(QGLView::qglReflectionsBlur)) {
|
||||
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 = 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;
|
||||
ri = 1 - lms;
|
||||
qDebug() << wi << ri << lms;
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(wi));
|
||||
glActiveTextureChannel(1);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_g.colorTexture(1));
|
||||
glActiveTextureChannel(2);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(lms));
|
||||
shader_ssr_merge->bind();
|
||||
shader_ssr_merge->setUniformValue("qgl_ModelViewProjectionMatrix", QMatrix4x4());
|
||||
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);
|
||||
glDrawQuad(shader_ssr_blur);
|
||||
wi = ri;
|
||||
|
||||
@@ -48,6 +48,7 @@ private:
|
||||
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_shadow, * shader_ssr, * shader_ssr_blur, * shader_ssr_merge;
|
||||
QGLShaderProgram * shader_ssao_blur, * shader_ssao_merge;
|
||||
QVector<ShaderPair> shaders;
|
||||
|
||||
QMatrix4x4 prev_view, prev_proj;
|
||||
|
||||
@@ -20,30 +20,23 @@ void main(void) {
|
||||
vec4 dc = qgl_FragColor;
|
||||
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;
|
||||
//if (acc_fog) dc.xyz = mix(dc.rgb, gl_Fog.color.rgb, fogCoord);
|
||||
|
||||
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;
|
||||
//float tx = dn.x;
|
||||
dn.y = -dn.y;
|
||||
//dn.y = tx;
|
||||
dn = TBN * dn;
|
||||
//dn = dn * mat3(qgl_ModelViewMatrix)*10;//*(mat3(qgl_NormalMatrix));
|
||||
n = normalize(qgl_NormalMatrix * (normal + dn));//normalize(qgl_NormalMatrix * (normal - dn));
|
||||
bn = normalize(qgl_NormalMatrix * binormal);//normalize(qgl_NormalMatrix * (normal - dn));
|
||||
n = normalize(qgl_NormalMatrix * (normal + dn));
|
||||
bn = normalize(qgl_NormalMatrix * binormal);
|
||||
//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;
|
||||
|
||||
vec4 spec = texture(qgl_Material.map_specular.map, tc) * qgl_Material.map_specular.amount + qgl_Material.map_specular.offset;
|
||||
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;
|
||||
self *= qgl_Material.color_self_illumination;
|
||||
|
||||
@@ -52,7 +45,7 @@ void main(void) {
|
||||
|
||||
//gl_FragDepth = logz;
|
||||
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[3] = vec4(self.rgb, bn.x);
|
||||
qgl_FragData[4] = vec4(speed.xy, bn.yz);
|
||||
|
||||
@@ -100,7 +100,7 @@ void main(void) {
|
||||
v3 = texelFetch(t3, tc, 0),
|
||||
v4 = texelFetch(t4, tc, 0);
|
||||
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));
|
||||
bn2 = normalize(cross(n, bn));
|
||||
float height = v2.w;
|
||||
@@ -127,13 +127,15 @@ void main(void) {
|
||||
//pos.z = v0.w;
|
||||
vec3 v = normalize(-pos.xyz);
|
||||
|
||||
sh_pow = 1. / max((1. - v1.w), 0.0001);
|
||||
sh_mul = max(1. - v1.w, 0.0001);
|
||||
float reflectivity = 0.;
|
||||
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)
|
||||
calcLight(i, 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 = li + vec3(texelFetch(t_pp, tc, 0).xyz);
|
||||
//shd = shd - shp.w;
|
||||
|
||||
@@ -16,7 +16,7 @@ void main(void) {
|
||||
for (int i = 0; i < steps; ++i) {
|
||||
ct += speed.xy * cdt;
|
||||
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;
|
||||
}
|
||||
scol /= sum;
|
||||
|
||||
@@ -18,20 +18,22 @@ void main(void) {
|
||||
vec4 spos = pos;
|
||||
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 rn = reflect(vd, n);
|
||||
//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;
|
||||
float reflectivity = 0.;
|
||||
float specularity = modf(v1.w, reflectivity);
|
||||
|
||||
rn.z = -rn.z;
|
||||
int i = 0;
|
||||
vec4 tv0;
|
||||
float l = z_far * 0.5;
|
||||
pos.xyz += rn * l;
|
||||
for (i = 0; i < 16; ++i) {
|
||||
for (i = 0; i < 20; ++i) {
|
||||
tpos = mat_proj * pos;
|
||||
tsp = -(tpos.xy / tpos.w) / 2. + 0.5;
|
||||
tv0 = texture(t0, tsp);
|
||||
@@ -43,8 +45,11 @@ void main(void) {
|
||||
ess = clamp(ess, vec2(0, 0), vec2(0.2, 0.2));
|
||||
ess = smoothstep(vec2(0.2, 0.2), vec2(0, 0), ess);
|
||||
coeff *= min(ess.x, ess.y);
|
||||
float blur = step(0., coeff) * length(pos.xyz - spos.xyz);
|
||||
vec3 rvs = texture(ts, tsp).rgb;
|
||||
vec4 pr_pos = mat_proj * pos, pr_spos = mat_proj * spos;
|
||||
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);
|
||||
vec4 v0 = texture(t0, tc);
|
||||
float rad;
|
||||
float coeff = modf(v0.a, rad);
|
||||
float coeff = modf(v0.a, rad) * 1.1;
|
||||
rad /= 10.;
|
||||
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( 0, o )).rgb, vec3(0)) * 2. +
|
||||
max(texture(t0, tc + dt * vec2( -o, 0 )).rgb, vec3(0)) * 2. +
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
#version 150
|
||||
|
||||
uniform sampler2D t0, ts;
|
||||
uniform sampler2D t0, tg1, ts;
|
||||
|
||||
void main(void) {
|
||||
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 coeff = modf(v0.a, rad);
|
||||
qgl_FragData[0].rgb = mix(vs.rgb, v0.rgb, coeff);
|
||||
//qgl_FragData[0].rgb = vec3(v0.rgb);
|
||||
float coeff = clamp(modf(v0.a, rad) * 1.1, 0., 1.);
|
||||
float reflectivity = 0.;
|
||||
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