git-svn-id: svn://db.shs.com.ru/libs@540 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -39,7 +39,7 @@ fbo_g(5, true, GL_RGBA16F), fbo_out(3, false, GL_RGBA16F), fbo_hsmall(1, false,
|
||||
<< ShaderPair("ssao_merge", &shader_ssao_merge)
|
||||
<< ShaderPair("dof", &shader_dof);
|
||||
for (int i = 0; i < shaders.size(); ++i)
|
||||
*(shaders[i].second) = 0;
|
||||
*(shaders[i].second) = nullptr;
|
||||
lights_per_pass = 8;
|
||||
tnoise = 0;
|
||||
exposure_ = 1.;
|
||||
@@ -73,12 +73,12 @@ void RendererDeferredShading::renderScene() {
|
||||
QMatrix4x4 mview = rp.view_matrix;
|
||||
QMatrix4x4 mviewi = rp.view_matrix_i;
|
||||
QMatrix4x4 mviewproji = (mproj * mview).inverted();
|
||||
QMatrix4x4 moffset = view.camera().offsetMatrix();
|
||||
QMatrix4x4 moffset = view.camera()->offsetMatrix();
|
||||
QMatrix4x4 moffseti = moffset.inverted();
|
||||
rp.prev_proj_matrix = prev_proj;
|
||||
rp.prev_view_matrix = prev_view;
|
||||
QMatrix4x4 vc_proji;
|
||||
vc_proji.perspective(90., 1., view.camera().depthStart(), view.camera().depthEnd());
|
||||
vc_proji.perspective(90., 1., view.camera()->depthStart(), view.camera()->depthEnd());
|
||||
vc_proji = vc_proji.inverted();
|
||||
corner_dirs[0] = (mproji * QVector4D( 1, 1, 0, 1));
|
||||
corner_dirs[1] = (mproji * QVector4D(-1, 1, 0, 1));
|
||||
@@ -89,30 +89,30 @@ void RendererDeferredShading::renderScene() {
|
||||
int buffs[] = {0, 1, 2, 3, 4};
|
||||
fbo_g.setWriteBuffers(buffs, 5);
|
||||
if (white_image_id == 0) {
|
||||
glActiveTextureChannel(6);
|
||||
glActiveTexture(GL_TEXTURE0 + 6);
|
||||
white_image_id = view.textureManager()->loadTexture(white_image, false);
|
||||
glBindTexture(GL_TEXTURE_2D, white_image_id);
|
||||
glActiveTextureChannel(0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
if (violent_image_id == 0) {
|
||||
glActiveTextureChannel(7);
|
||||
glActiveTexture(GL_TEXTURE0 + 7);
|
||||
violent_image_id = view.textureManager()->loadTexture(violent_image, false);
|
||||
glBindTexture(GL_TEXTURE_2D, violent_image_id);
|
||||
glActiveTextureChannel(0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
glClearFramebuffer(QColor(0, 0, 0, 0));
|
||||
glDisable(GL_RESCALE_NORMAL);
|
||||
glEnableDepth();
|
||||
shader_ds_0->bind();
|
||||
rp.setUniform(shader_ds_0);
|
||||
shader_ds_0->setUniformValue("z_far", GLfloat(view.depthEnd()));
|
||||
shader_ds_0->setUniformValue("z_near", GLfloat(view.depthStart()));
|
||||
shader_ds_0->setUniformValue("z_far", view.depthEnd());
|
||||
shader_ds_0->setUniformValue("z_near", view.depthStart());
|
||||
shader_ds_0->setUniformValue("t0", 0);
|
||||
shader_ds_0->setUniformValue("t1", 1);
|
||||
shader_ds_0->setUniformValue("t2", 2);
|
||||
shader_ds_0->setUniformValue("t3", 3);
|
||||
shader_ds_0->setUniformValue("t4", 4);
|
||||
shader_ds_0->setUniformValue("dt", QVector2D(1. / view.width(), 1. / view.height()));
|
||||
shader_ds_0->setUniformValue("dt", QVector2D(1.f / view.width(), 1.f / view.height()));
|
||||
//qDebug() << rp.view_matrix << prev_view;
|
||||
//shader_ds_0->setUniformValue("qgl_ModelViewMatrix", rp.view_matrix);
|
||||
renderObjects(GLObjectBase::Solid, 0, shader_ds_0, true, false, false);
|
||||
@@ -156,8 +156,8 @@ void RendererDeferredShading::renderScene() {
|
||||
rp.prepare();
|
||||
//qDebug() << rp.view_matrix;
|
||||
shader_ds_1->bind();
|
||||
shader_ds_1->setUniformValue("z_far", GLfloat(view.depthEnd()));
|
||||
shader_ds_1->setUniformValue("z_near", GLfloat(view.depthStart()));
|
||||
shader_ds_1->setUniformValue("z_far", view.depthEnd());
|
||||
shader_ds_1->setUniformValue("z_near", view.depthStart());
|
||||
shader_ds_1->setUniformValue("t0", 0);
|
||||
shader_ds_1->setUniformValue("t1", 1);
|
||||
shader_ds_1->setUniformValue("t2", 2);
|
||||
@@ -170,7 +170,7 @@ void RendererDeferredShading::renderScene() {
|
||||
shader_ds_1->setUniformValue("mat_viewi", mviewi);
|
||||
shader_ds_1->setUniformValue("mat_viewproji", mviewproji);
|
||||
shader_ds_1->setUniformValue("shadow_on", view.isFeatureEnabled(QGLView::qglShadowsEnabled) ? 1 : 0);
|
||||
shader_ds_1->setUniformValue("dt", QVector2D(1. / view.width(), 1. / view.height()));
|
||||
shader_ds_1->setUniformValue("dt", QVector2D(1.f / view.width(), 1.f / view.height()));
|
||||
rp.setUniform(shader_ds_1);
|
||||
fbo_g.bindColorTextures();
|
||||
fbo_g.bindDepthTexture(5);
|
||||
@@ -188,7 +188,7 @@ void RendererDeferredShading::renderScene() {
|
||||
wi = 1 - l % 2;
|
||||
ri = l % 2;
|
||||
//qDebug() << " pass" << l << "read from" << ri << "write to" << wi;
|
||||
glActiveTextureChannel(6);
|
||||
glActiveTexture(GL_TEXTURE0 + 6);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(ri));
|
||||
fbo_out.setWriteBuffer(wi);
|
||||
setupDSLights(l, mview * moffset);
|
||||
@@ -198,25 +198,25 @@ void RendererDeferredShading::renderScene() {
|
||||
//fbo_out.release();
|
||||
wi = 1 - passes % 2;
|
||||
ri = passes % 2;
|
||||
glActiveTextureChannel(0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(ri));
|
||||
|
||||
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);
|
||||
glActiveTexture(GL_TEXTURE0 + 1);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(2));
|
||||
glActiveTextureChannel(2);
|
||||
glActiveTexture(GL_TEXTURE0 + 2);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_g.colorTexture(1));
|
||||
glActiveTextureChannel(0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
//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("dt", QVector2D(1.f / fbo_out.width(), 1.f / fbo_out.height()));
|
||||
shader_ssao_blur->setUniformValue("t0", 0);
|
||||
shader_ssao_blur->setUniformValue("ts", 1);
|
||||
shader_ssao_blur->setUniformValue("tg1", 2);
|
||||
@@ -249,18 +249,18 @@ void RendererDeferredShading::renderScene() {
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(lri));
|
||||
glActiveTextureChannel(1);
|
||||
glActiveTexture(GL_TEXTURE0 + 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);
|
||||
glActiveTexture(GL_TEXTURE0 + 2);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_g.colorTexture(1));
|
||||
glActiveTextureChannel(3);
|
||||
glActiveTexture(GL_TEXTURE0 + 3);
|
||||
glBindTexture(GL_TEXTURE_1D, tnoise);
|
||||
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("z_far", view.depthEnd());
|
||||
shader_ssao_merge->setUniformValue("z_near", view.depthStart());
|
||||
shader_ssao_merge->setUniformValue("mat_proj", mproj);
|
||||
shader_ssao_merge->setUniformValue("n0", 3);
|
||||
shader_ssao_merge->setUniformValue("t0", 0);
|
||||
@@ -273,27 +273,27 @@ void RendererDeferredShading::renderScene() {
|
||||
ri = lwi;
|
||||
//piSwap<int>(wi, ri);
|
||||
|
||||
glActiveTextureChannel(0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(ri));
|
||||
//piSwap<int>(wi, ri);
|
||||
}
|
||||
|
||||
if (view.isFeatureEnabled(QGLView::qglReflectionsEnabled)) {
|
||||
fbo_out.setWriteBuffer(2);
|
||||
glActiveTextureChannel(0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(ri));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);//_MIPMAP_LINEAR);
|
||||
//glGenerateMipmap(GL_TEXTURE_2D);
|
||||
glActiveTextureChannel(1);
|
||||
glActiveTexture(GL_TEXTURE0 + 1);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_g.colorTexture(0));
|
||||
glActiveTextureChannel(2);
|
||||
glActiveTexture(GL_TEXTURE0 + 2);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_g.colorTexture(1));
|
||||
fbo_g.bindDepthTexture(7);
|
||||
shader_ssr->bind();
|
||||
shader_ssr->setUniformValue("qgl_ModelViewProjectionMatrix", QMatrix4x4());
|
||||
shader_ssr->setUniformValue("z_far", GLfloat(view.depthEnd()));
|
||||
shader_ssr->setUniformValue("z_near", GLfloat(view.depthStart()));
|
||||
shader_ssr->setUniformValue("z_far", view.depthEnd());
|
||||
shader_ssr->setUniformValue("z_near", view.depthStart());
|
||||
shader_ssr->setUniformValue("mat_proj", mproj);
|
||||
shader_ssr->setUniformValue("t0", 1);
|
||||
shader_ssr->setUniformValue("t1", 2);
|
||||
@@ -301,12 +301,12 @@ void RendererDeferredShading::renderScene() {
|
||||
shader_ssr->setUniformValue("td", 7);
|
||||
glDrawQuad(shader_ssr, corner_dirs);
|
||||
|
||||
glActiveTextureChannel(0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
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("dt", QVector2D(1.f / fbo_out.width(), 1.f / fbo_out.height()));
|
||||
shader_ssr_blur->setUniformValue("t0", 0);
|
||||
int passes = 5;
|
||||
int crad = 1;
|
||||
@@ -326,9 +326,9 @@ void RendererDeferredShading::renderScene() {
|
||||
ri = 1 - lms;
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(wi));
|
||||
glActiveTextureChannel(1);
|
||||
glActiveTexture(GL_TEXTURE0 + 1);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_g.colorTexture(1));
|
||||
glActiveTextureChannel(2);
|
||||
glActiveTexture(GL_TEXTURE0 + 2);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(lms));
|
||||
shader_ssr_merge->bind();
|
||||
shader_ssr_merge->setUniformValue("qgl_ModelViewProjectionMatrix", QMatrix4x4());
|
||||
@@ -341,7 +341,7 @@ void RendererDeferredShading::renderScene() {
|
||||
ri = 1 - ri;
|
||||
//piSwap<int>(wi, ri);
|
||||
|
||||
glActiveTextureChannel(0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(wi));
|
||||
piSwap<int>(wi, ri);
|
||||
}
|
||||
@@ -353,43 +353,43 @@ void RendererDeferredShading::renderScene() {
|
||||
fbo_g.bind();
|
||||
glReadPixels(fbo_out.width() / 2, fbo_out.height() / 2, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &cw);
|
||||
fbo_out.bind();
|
||||
const double _pe = 2.4e-7;
|
||||
double cz = cw + cw - 1;
|
||||
cz = ((_pe - 2.) * view.depthStart()) / (cz + _pe - 1.); // infinite depth
|
||||
double z = view.feature(QGLView::qglDepthOfFieldFocus).toDouble(),
|
||||
s = view.feature(QGLView::qglDepthOfFieldAutoFocusSpeed).toDouble();
|
||||
z = z * (1. - s) + cz * s;
|
||||
const float _pe = 2.4e-7f;
|
||||
float cz = cw + cw - 1;
|
||||
cz = ((_pe - 2.f) * view.depthStart()) / (cz + _pe - 1.f); // infinite depth
|
||||
float z = view.feature(QGLView::qglDepthOfFieldFocus).toFloat(),
|
||||
s = view.feature(QGLView::qglDepthOfFieldAutoFocusSpeed).toFloat();
|
||||
z = z * (1.f - s) + cz * s;
|
||||
view.setFeature(QGLView::qglDepthOfFieldFocus, z);
|
||||
}
|
||||
shader_dof->bind();
|
||||
shader_dof->setUniformValue("qgl_ModelViewProjectionMatrix", QMatrix4x4());
|
||||
shader_dof->setUniformValue("z_far", GLfloat(view.depthEnd()));
|
||||
shader_dof->setUniformValue("z_near", GLfloat(view.depthStart()));
|
||||
shader_dof->setUniformValue("focus", GLfloat(view.feature(QGLView::qglDepthOfFieldFocus).toDouble()));
|
||||
shader_dof->setUniformValue("diaphragm", GLfloat(view.feature(QGLView::qglDepthOfFieldDiaphragm).toDouble()));
|
||||
shader_dof->setUniformValue("z_far", view.depthEnd());
|
||||
shader_dof->setUniformValue("z_near", view.depthStart());
|
||||
shader_dof->setUniformValue("focus", view.feature(QGLView::qglDepthOfFieldFocus).toFloat());
|
||||
shader_dof->setUniformValue("diaphragm", view.feature(QGLView::qglDepthOfFieldDiaphragm).toFloat());
|
||||
shader_dof->setUniformValue("t0", 0);
|
||||
shader_dof->setUniformValue("td", 7);
|
||||
fbo_g.bindDepthTexture(7);
|
||||
glActiveTextureChannel(0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
int passes = 3;
|
||||
float crad = 1.;
|
||||
for (int p = 0; p < passes; ++p) {
|
||||
shader_dof->setUniformValue("radius", GLfloat(crad));
|
||||
shader_dof->setUniformValue("radius", crad);
|
||||
fbo_out.setWriteBuffer(wi);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(ri));
|
||||
shader_dof->setUniformValue("dt", QVector2D(1. / fbo_out.width(), 0.));
|
||||
shader_dof->setUniformValue("dt", QVector2D(1.f / fbo_out.width(), 0.f));
|
||||
glDrawQuad(shader_dof);
|
||||
piSwap<int>(wi, ri);
|
||||
fbo_out.setWriteBuffer(wi);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(ri));
|
||||
shader_dof->setUniformValue("dt", QVector2D(0., 1. / fbo_out.height()));
|
||||
shader_dof->setUniformValue("dt", QVector2D(0.f, 1.f / fbo_out.height()));
|
||||
glDrawQuad(shader_dof);
|
||||
piSwap<int>(wi, ri);
|
||||
crad *= 2.;
|
||||
crad *= 2.f;
|
||||
}
|
||||
|
||||
glActiveTextureChannel(0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(ri));
|
||||
}
|
||||
|
||||
@@ -411,11 +411,11 @@ void RendererDeferredShading::renderScene() {
|
||||
//if (min[2] > hcontent[i].z) min[2] = hcontent[i].z;
|
||||
if (max[2] < hcontent[i].z) max[2] = hcontent[i].z;
|
||||
}
|
||||
GLfloat mluma = (0.299 * max[0]) + (0.587 * max[1]) + (0.114 * max[2]);
|
||||
double nexp = mluma / 16., dexp = nexp - exposure_, mestep = exposure_ * view.feature(QGLView::qglEyeAccomodationMaxSpeed).toDouble();
|
||||
dexp /= view.feature(QGLView::qglEyeAccomodationTime).toDouble();
|
||||
if (dexp > 0. && dexp > mestep/4) dexp = mestep/4;
|
||||
if (dexp < 0. && dexp < -mestep) dexp = -mestep;
|
||||
GLfloat mluma = (0.299f * max[0]) + (0.587f * max[1]) + (0.114f * max[2]);
|
||||
float nexp = mluma / 16.f, dexp = nexp - exposure_, mestep = exposure_ * view.feature(QGLView::qglEyeAccomodationMaxSpeed).toFloat();
|
||||
dexp /= view.feature(QGLView::qglEyeAccomodationTime).toFloat();
|
||||
if (dexp > 0.f && dexp > mestep/4) dexp = mestep/4;
|
||||
if (dexp < 0.f && dexp < -mestep) dexp = -mestep;
|
||||
exposure_ += dexp;
|
||||
label_exp->setText(QString("exposure: %1").arg(exposure_));
|
||||
label_exp_step->setText(QString("d_exposure: %1").arg(dexp));
|
||||
@@ -428,7 +428,7 @@ void RendererDeferredShading::renderScene() {
|
||||
shader_hdr->bind();
|
||||
shader_hdr->setUniformValue("qgl_ModelViewProjectionMatrix", QMatrix4x4());
|
||||
shader_hdr->setUniformValue("t0", 0);
|
||||
shader_hdr->setUniformValue("exposure", GLfloat(1./exposure_));
|
||||
shader_hdr->setUniformValue("exposure", GLfloat(1.f/exposure_));
|
||||
glDrawQuad(shader_hdr);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(wi));
|
||||
piSwap<int>(wi, ri);
|
||||
@@ -436,17 +436,17 @@ void RendererDeferredShading::renderScene() {
|
||||
|
||||
if (view.isFeatureEnabled(QGLView::qglMotionBlurEnabled)) {
|
||||
fbo_out.setWriteBuffer(wi);
|
||||
glActiveTextureChannel(1);
|
||||
glActiveTexture(GL_TEXTURE0 + 1);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_g.colorTexture(4));
|
||||
shader_motion_blur->bind();
|
||||
shader_motion_blur->setUniformValue("qgl_ModelViewProjectionMatrix", QMatrix4x4());
|
||||
shader_motion_blur->setUniformValue("dt", QVector2D(1. / fbo_out.width(), 1. / fbo_out.height()));
|
||||
shader_motion_blur->setUniformValue("dt", QVector2D(1.f / fbo_out.width(), 1.f / fbo_out.height()));
|
||||
shader_motion_blur->setUniformValue("t0", 0);
|
||||
shader_motion_blur->setUniformValue("ts", 1);
|
||||
shader_motion_blur->setUniformValue("factor", GLfloat(view.feature(QGLView::qglMotionBlurFactor).toDouble()));
|
||||
shader_motion_blur->setUniformValue("factor", view.feature(QGLView::qglMotionBlurFactor).toFloat());
|
||||
shader_motion_blur->setUniformValue("steps", view.feature(QGLView::qglMotionBlurSteps).toInt());
|
||||
glDrawQuad(shader_motion_blur);
|
||||
glActiveTextureChannel(0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(wi));
|
||||
piSwap<int>(wi, ri);
|
||||
}
|
||||
@@ -460,16 +460,16 @@ void RendererDeferredShading::renderScene() {
|
||||
fbo_out.setWriteBuffer(wi);
|
||||
shader_bloom_0->bind();
|
||||
shader_bloom_0->setUniformValue("qgl_ModelViewProjectionMatrix", QMatrix4x4());
|
||||
shader_bloom_0->setUniformValue("factor", GLfloat(view.feature(QGLView::qglBloomFactor).toDouble()));
|
||||
shader_bloom_0->setUniformValue("threshold", GLfloat(view.feature(QGLView::qglBloomThreshold).toDouble()));
|
||||
shader_bloom_0->setUniformValue("factor", view.feature(QGLView::qglBloomFactor).toFloat());
|
||||
shader_bloom_0->setUniformValue("threshold", view.feature(QGLView::qglBloomThreshold).toFloat());
|
||||
shader_bloom_0->setUniformValue("t0", 0);
|
||||
glDrawQuad(shader_bloom_0);
|
||||
glActiveTextureChannel(0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
piSwap<int>(wi, ri);
|
||||
|
||||
shader_bloom_1->bind();
|
||||
shader_bloom_1->setUniformValue("qgl_ModelViewProjectionMatrix", QMatrix4x4());
|
||||
shader_bloom_1->setUniformValue("dt", QVector2D(1. / fbo_out.width(), 1. / fbo_out.height()));
|
||||
shader_bloom_1->setUniformValue("dt", QVector2D(1.f / fbo_out.width(), 1.f / fbo_out.height()));
|
||||
shader_bloom_1->setUniformValue("t0", 0);
|
||||
int radius = view.feature(QGLView::qglBloomRadius).toInt();
|
||||
int passes = qMax<int>(int(ceil(log2(radius))), 1);
|
||||
@@ -486,28 +486,28 @@ void RendererDeferredShading::renderScene() {
|
||||
}
|
||||
//qDebug() << tm.elapsed();
|
||||
fbo_out.setWriteBuffer(wi);
|
||||
glActiveTextureChannel(0);
|
||||
// glActiveTextureChannel(0);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(ri));
|
||||
glActiveTextureChannel(1);
|
||||
glActiveTexture(GL_TEXTURE0 + 1);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(2));
|
||||
shader_fbo_add->bind();
|
||||
shader_fbo_add->setUniformValue("qgl_ModelViewProjectionMatrix", QMatrix4x4());
|
||||
shader_fbo_add->setUniformValue("t0", 0);
|
||||
shader_fbo_add->setUniformValue("t1", 1);
|
||||
glDrawQuad(shader_fbo_add);
|
||||
glActiveTextureChannel(0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(wi));
|
||||
piSwap<int>(wi, ri);
|
||||
}
|
||||
|
||||
glReleaseShaders();
|
||||
glUseProgram(0);
|
||||
fbo_out.release();
|
||||
|
||||
if (view.isFeatureEnabled(QGLView::qglFXAA)) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
shader_fxaa->bind();
|
||||
shader_fxaa->setUniformValue("dt", QVector2D(1. / view.width(), 1. / view.height()));
|
||||
shader_fxaa->setUniformValue("dt", QVector2D(1.f / view.width(), 1.f / view.height()));
|
||||
} else {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
@@ -546,9 +546,9 @@ void RendererDeferredShading::reloadShaders() {
|
||||
|
||||
|
||||
void RendererDeferredShading::setupShadersTextures(GLObjectBase & object, GLRendererBase::RenderingParameters & rp) {
|
||||
glActiveTextureChannel(6);
|
||||
glActiveTexture(GL_TEXTURE0 + 6);
|
||||
glBindTexture(GL_TEXTURE_2D, white_image_id);
|
||||
glActiveTextureChannel(7);
|
||||
glActiveTexture(GL_TEXTURE0 + 7);
|
||||
glBindTexture(GL_TEXTURE_2D, violent_image_id);
|
||||
}
|
||||
|
||||
@@ -566,7 +566,7 @@ void RendererDeferredShading::setupDSLights(int pass, const QMatrix4x4 & view_ma
|
||||
QVector<Light*> lv;
|
||||
for (int i = light_start; i < light_end; ++i) {
|
||||
lv << view.lights()[i];
|
||||
glActiveTextureChannel(shadow_start + i - light_start);
|
||||
glActiveTexture(GL_TEXTURE0 + shadow_start + i - light_start);
|
||||
glBindTexture(GL_TEXTURE_2D, lv.back()->shadow_map.depthTexture());
|
||||
if (view.isFeatureEnabled(QGLView::qglShadowsSoftEnabled)) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
|
||||
Reference in New Issue
Block a user