]> git.tdb.fi Git - libs/gl.git/commitdiff
Improve state setting in Sky
authorMikko Rasa <tdb@tdb.fi>
Mon, 20 Dec 2021 00:13:41 +0000 (02:13 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 20 Dec 2021 00:14:45 +0000 (02:14 +0200)
Avoid leaking the effect's shader data to its content as it contains no
relevant uniforms.

source/effects/sky.cpp

index fc6d49fd37385e908ca57e4480b1ec61f6190e8f..a11a76a971bad75f2c6b82f9933af39ddf0db193 100644 (file)
@@ -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);
 }