git-svn-id: svn://db.shs.com.ru/libs@659 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2019-12-06 13:47:45 +00:00
parent c5bbf5ef8f
commit 6c409d0e12
14 changed files with 167 additions and 125 deletions

View File

@@ -30,9 +30,8 @@ using namespace QGLEngineShaders;
Renderer::Renderer(QGLView * view_): RendererBase(view_),
fbo_ds (view_, QVector<GLenum>() << GL_RGBA16F << GL_RGBA32F << GL_RGBA16F << GL_RGBA16F << GL_RGBA16F),
fbo_out (view_, 6, false, GL_RGBA16F),
fbo_small_4 (view_, 1, false, GL_RGBA16F),
fbo_small_16 (view_, 1, false, GL_RGBA16F),
fbo_1x1 (view_, 1, false, GL_RGB32F ),
fbomm(fbo_out, obrSum, 3),
buffer_vbo(GL_ARRAY_BUFFER, GL_DYNAMIC_DRAW),
rend_mat(this), rend_service(this), rend_selection(this) {
shader_sum = 0;
@@ -104,8 +103,7 @@ void Renderer::resize(int width, int height) {
rend_selection.resize(width, height);
fbo_ds .resize(width, height);
fbo_out .resize(width, height);
fbo_small_4 .resize(width / 4 , height / 4 );
fbo_small_16 .resize(width / 16, height / 16);
fbomm.resize();
resizeSum();
}
@@ -228,12 +226,12 @@ void Renderer::prepareSum() {
void Renderer::resizeSum() {
QOpenGLExtraFunctions * f = view;
int pcnt = fbo_small_16.width() * fbo_small_16.height();
int pcnt = fbomm.width(fbomm.lastLevel()) * fbomm.height(fbomm.lastLevel());
QVector<Vector2i> _data;
_data.resize(pcnt);
pcnt = -1;
for (int x = 0; x < fbo_small_16.width(); ++x)
for (int y = 0; y < fbo_small_16.height(); ++y)
for (int x = 0; x < fbomm.width(fbomm.lastLevel()); ++x)
for (int y = 0; y < fbomm.height(fbomm.lastLevel()); ++y)
_data[++pcnt] = Vector2i(x,y);
buffer_vbo.bind(f);
buffer_vbo.resize(f, _data.size() * sizeof(Vector2i));
@@ -348,11 +346,11 @@ void Renderer::renderScene() {
fbo_out.setWriteBuffer(obrSum);
renderQuad(prog, quad);
}
fbo_out.blit(obrSum, fbo_small_4.id(), 0, fbo_out.rect(), fbo_small_4.rect(), GL_COLOR_BUFFER_BIT, GL_LINEAR);
fbo_small_4.blit(0, fbo_small_16.id(), 0, fbo_small_4.rect(), fbo_small_16.rect(), GL_COLOR_BUFFER_BIT, GL_LINEAR);
renderSum(fbo_small_16, 0);
fbomm.create();
renderSum(fbomm.plane(fbomm.lastLevel()), 0);
fbo_out.bind();
if (bindShader(srTonemapPass, &prog)) {
prog->setUniformValue("exposure", exposure_);
fbo_1x1.bindColorTexture(0, 1);
fbo_out.bindColorTexture(obrSum, 0);
fbo_out.setWriteBuffer(obrTonemap);