From a9e3cf282bd9c5c43e767552b73068e7a56765e2 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 20 Dec 2021 02:13:41 +0200 Subject: [PATCH] Improve state setting in Sky Avoid leaking the effect's shader data to its content as it contains no relevant uniforms. --- source/effects/sky.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/source/effects/sky.cpp b/source/effects/sky.cpp index fc6d49fd..a11a76a9 100644 --- a/source/effects/sky.cpp +++ b/source/effects/sky.cpp @@ -101,21 +101,25 @@ void Sky::setup_frame(Renderer &renderer) shdata.uniform("light_dir", -sun.get_direction()); sun.set_transmittance(get_transmittance(-sun.get_direction())); - Renderer::Push push(renderer); - - if(transmittance_lookup_dirty) { - transmittance_lookup_dirty = false; - renderer.set_framebuffer(&transmittance_lookup.get_framebuffer()); - renderer.set_shader_program(&transmittance_shprog, &shdata); + Renderer::Push push(renderer); + + renderer.add_shader_data(shdata); + + if(transmittance_lookup_dirty) + { + transmittance_lookup_dirty = false; + renderer.set_framebuffer(&transmittance_lookup.get_framebuffer()); + renderer.set_shader_program(&transmittance_shprog); + fullscreen_mesh.draw(renderer); + } + + renderer.set_framebuffer(&distant.get_framebuffer()); + renderer.set_shader_program(&distant_shprog); + renderer.set_texture("transmittance_lookup", &transmittance_lookup.get_target_texture(0), &sampler); fullscreen_mesh.draw(renderer); } - renderer.set_framebuffer(&distant.get_framebuffer()); - renderer.set_shader_program(&distant_shprog, &shdata); - renderer.set_texture("transmittance_lookup", &transmittance_lookup.get_target_texture(0), &sampler); - fullscreen_mesh.draw(renderer); - content.setup_frame(renderer); } -- 2.45.2