X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Feffects%2Fambientocclusion.cpp;h=d23469edf8aeeac20a0a62cf285e47dde551f019;hp=8c1dd616c4b53ba40b49aea69bfd237bd89e1b17;hb=fe2fc291a4fc618425c64112c9ffd3519f0b8a3e;hpb=7aaec9a70b8d7733429bec043f8e33e02956f266 diff --git a/source/effects/ambientocclusion.cpp b/source/effects/ambientocclusion.cpp index 8c1dd616..d23469ed 100644 --- a/source/effects/ambientocclusion.cpp +++ b/source/effects/ambientocclusion.cpp @@ -3,6 +3,7 @@ #include "blend.h" #include "camera.h" #include "renderer.h" +#include "resources.h" #include "shader.h" #include "tests.h" @@ -13,14 +14,12 @@ namespace GL { AmbientOcclusion::AmbientOcclusion(unsigned w, unsigned h, float): occlude_target(w, h, (RENDER_COLOR,R8)), - occlude_shader("ambientocclusion_occlude.glsl"), - combine_shader("ambientocclusion_combine.glsl"), - quad(get_fullscreen_quad()), - linear_sampler(get_linear_sampler()), - nearest_sampler(get_nearest_sampler()) + occlude_shader(Resources::get_global().get("_ambientocclusion_occlude.glsl.shader")), + combine_shader(Resources::get_global().get("_ambientocclusion_combine.glsl.shader")), + quad(Resources::get_global().get("_fullscreen_quad.mesh")), + linear_sampler(Resources::get_global().get("_linear_clamp.samp")), + nearest_sampler(Resources::get_global().get("_nearest_clamp.samp")) { - texturing.attach(2, occlude_target.get_target_texture(RENDER_COLOR), linear_sampler.get()); - unsigned seed = 1; rotate_lookup.storage(RGBA8, 4, 4, 1); unsigned char data[64]; @@ -36,12 +35,6 @@ AmbientOcclusion::AmbientOcclusion(unsigned w, unsigned h, float): } rotate_lookup.image(0, data); - texturing.attach(3, rotate_lookup, nearest_sampler.get()); - - shdata.uniform("source", 0); - shdata.uniform("depth", 1); - shdata.uniform("occlusion", 2); - shdata.uniform("rotate", 3); shdata.uniform("inverse_projection", Matrix()); set_n_samples(16); @@ -91,23 +84,23 @@ void AmbientOcclusion::set_edge_depth_threshold(float edt) void AmbientOcclusion::render(Renderer &renderer, const Texture2D &color, const Texture2D &depth) { - texturing.attach(0, color, nearest_sampler.get()); - texturing.attach(1, depth, nearest_sampler.get()); - if(renderer.get_camera()) shdata.uniform("inverse_projection", invert(renderer.get_camera()->get_projection_matrix())); Renderer::Push push(renderer); - renderer.set_texturing(&texturing); + renderer.set_texture("source", &color, &nearest_sampler); + renderer.set_texture("depth", &depth, &nearest_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); { BindRestore bind_fbo(occlude_target.get_framebuffer()); - quad->draw(renderer); + quad.draw(renderer); } renderer.set_shader_program(&combine_shader); - quad->draw(renderer); + quad.draw(renderer); }