]> git.tdb.fi Git - libs/gl.git/commitdiff
Do discard-clears in individual postprocessors, not the sequence
authorMikko Rasa <tdb@tdb.fi>
Sat, 20 Nov 2021 21:43:33 +0000 (23:43 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 20 Nov 2021 21:43:33 +0000 (23:43 +0200)
It should be done just before rendering into the target starts.

source/effects/ambientocclusion.cpp
source/effects/bloom.cpp
source/effects/colorcurve.cpp
source/render/sequence.cpp

index 96fc7317a9b2fe5727c66f6bdea5362496cd5d76..350c6423dd4ac21c5335f91402cd08eeb7d23494 100644 (file)
@@ -110,9 +110,11 @@ void AmbientOcclusion::render(Renderer &renderer, const Texture2D &color, const
        renderer.set_shader_program(&occlude_shader, &shdata);
 
        renderer.set_framebuffer(&occlude_target.get_framebuffer());
+       renderer.clear(0);
        quad.draw(renderer);
 
        renderer.set_framebuffer(out_fbo);
+       renderer.clear(0);
        renderer.set_shader_program(&combine_shader);
        quad.draw(renderer);
 }
index 8a8dea3ed687752ea408c4efdbb4b5ce0f06cc2a..7795e191faa0ca6aca0ceb472bea430a5b067e5f 100644 (file)
@@ -68,11 +68,13 @@ void Bloom::render(Renderer &renderer, const Texture2D &src, const Texture2D &)
        {
                Renderer::Push push2(renderer);
                renderer.set_framebuffer(&target[i]->get_framebuffer());
+               renderer.clear(0);
                renderer.set_texture("source", (i ? &target[0]->get_target_texture(COLOR_ATTACHMENT) : &src), &nearest_sampler);
                renderer.add_shader_data(blur_shdata[i]);
                quad.draw(renderer);
        }
 
+       renderer.clear(0);
        renderer.set_texture("source", &src, &nearest_sampler);
        renderer.set_texture("blurred", &target[1]->get_target_texture(COLOR_ATTACHMENT), &linear_sampler);
        renderer.set_shader_program(&combine_shader);
index 30cb2bc7b6621ab8fe1452434a2a9b206f974c49..ba76a9647d2ff789e2991276d2742c520bd0ba63 100644 (file)
@@ -69,6 +69,7 @@ void ColorCurve::set_linear()
 void ColorCurve::render(Renderer &renderer, const Texture2D &color_buf, const Texture2D &)
 {
        Renderer::Push push(renderer);
+       renderer.clear(0);
        renderer.set_shader_program(&shprog, &shdata);
        renderer.set_texture("source", &color_buf, &nearest_sampler);
        renderer.set_texture("curve", &curve, &linear_sampler);
index b11d4b1c9f037aafbfe49eaebe2d76c1920d5511..74b8bc3b0b4fe9a6835d9f5fab5326dddcc62fe3 100644 (file)
@@ -154,7 +154,6 @@ void Sequence::render(Renderer &renderer, Tag tag) const
                {
                        unsigned j = i%2;
                        renderer.set_framebuffer(i+1<postproc.size() ? &target[1-j]->get_framebuffer() : out_fbo);
-                       renderer.clear(0);
                        const Texture2D &color = target[j]->get_target_texture(COLOR_ATTACHMENT);
                        const Texture2D &depth = target[j]->get_target_texture(DEPTH_ATTACHMENT);
                        postproc[i]->render(renderer, color, depth);