]> git.tdb.fi Git - libs/gl.git/blobdiff - source/effects/ambientocclusion.cpp
Use correct sampler for the ambient occlusion rotate lookup
[libs/gl.git] / source / effects / ambientocclusion.cpp
index d23469edf8aeeac20a0a62cf285e47dde551f019..bbff1f25b45d5c7bad60768e96be28f8b0bbf427 100644 (file)
@@ -18,7 +18,8 @@ AmbientOcclusion::AmbientOcclusion(unsigned w, unsigned h, float):
        combine_shader(Resources::get_global().get<Program>("_ambientocclusion_combine.glsl.shader")),
        quad(Resources::get_global().get<Mesh>("_fullscreen_quad.mesh")),
        linear_sampler(Resources::get_global().get<Sampler>("_linear_clamp.samp")),
-       nearest_sampler(Resources::get_global().get<Sampler>("_nearest_clamp.samp"))
+       nearest_clamp_sampler(Resources::get_global().get<Sampler>("_nearest_clamp.samp")),
+       nearest_sampler(Resources::get_global().get<Sampler>("_nearest.samp"))
 {
        unsigned seed = 1;
        rotate_lookup.storage(RGBA8, 4, 4, 1);
@@ -35,8 +36,6 @@ AmbientOcclusion::AmbientOcclusion(unsigned w, unsigned h, float):
        }
        rotate_lookup.image(0, data);
 
-       shdata.uniform("inverse_projection", Matrix());
-
        set_n_samples(16);
        set_occlusion_radius(0.5f);
        set_darkness(1.0f);
@@ -84,12 +83,9 @@ void AmbientOcclusion::set_edge_depth_threshold(float edt)
 
 void AmbientOcclusion::render(Renderer &renderer, const Texture2D &color, const Texture2D &depth)
 {
-       if(renderer.get_camera())
-               shdata.uniform("inverse_projection", invert(renderer.get_camera()->get_projection_matrix()));
-
        Renderer::Push push(renderer);
-       renderer.set_texture("source", &color, &nearest_sampler);
-       renderer.set_texture("depth", &depth, &nearest_sampler);
+       renderer.set_texture("source", &color, &nearest_clamp_sampler);
+       renderer.set_texture("depth", &depth, &nearest_clamp_sampler);
        renderer.set_texture("occlusion", &occlude_target.get_target_texture(RENDER_COLOR), &linear_sampler);
        renderer.set_texture("rotate", &rotate_lookup, &nearest_sampler);
        renderer.set_shader_program(&occlude_shader, &shdata);