X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Feffects%2Fbloom.cpp;h=98afedfc17c924e1e1b1048488dd0e72497ce4dc;hb=6f39983060a27634c012f66c82fea0d09fea9774;hp=ee7c76c3217bef3befc48e40b794d3f485cb4389;hpb=7aaec9a70b8d7733429bec043f8e33e02956f266;p=libs%2Fgl.git diff --git a/source/effects/bloom.cpp b/source/effects/bloom.cpp index ee7c76c3..98afedfc 100644 --- a/source/effects/bloom.cpp +++ b/source/effects/bloom.cpp @@ -4,6 +4,7 @@ #include "bloom.h" #include "misc.h" #include "renderer.h" +#include "resources.h" #include "shader.h" #include "tests.h" #include "texunit.h" @@ -13,12 +14,12 @@ using namespace std; namespace Msp { namespace GL { -Bloom::Bloom(unsigned w, unsigned h): - blur_shader("bloom_blur.glsl"), - combine_shader("bloom_combine.glsl"), - quad(get_fullscreen_quad()), - nearest_sampler(get_nearest_sampler()), - linear_sampler(get_linear_sampler()) +Bloom::Bloom(Resources &resources, unsigned w, unsigned h): + blur_shader(resources.get("_bloom_blur.glsl.shader")), + combine_shader(resources.get("_bloom_combine.glsl.shader")), + quad(resources.get("_fullscreen_quad.mesh")), + nearest_sampler(resources.get("_nearest_clamp.samp")), + linear_sampler(resources.get("_linear_clamp.samp")) { blur_shdata[0].uniform("delta", 1.0f/w, 0.0f); blur_shdata[1].uniform("delta", 0.0f, 1.0f/h); @@ -26,11 +27,6 @@ Bloom::Bloom(unsigned w, unsigned h): for(unsigned i=0; i<2; ++i) target[i] = new RenderTarget(w, h, (RENDER_COLOR,RGB16F)); - common_shdata.uniform("source", 0); - common_shdata.uniform("blurred", 1); - - combine_texturing.attach(1, target[1]->get_target_texture(RENDER_COLOR), linear_sampler.get()); - set_radius(2.0f); set_strength(0.2f); } @@ -75,15 +71,15 @@ void Bloom::render(Renderer &renderer, const Texture2D &src, const Texture2D &) { BindRestore bind_fbo(target[i]->get_framebuffer()); Renderer::Push push2(renderer); - renderer.set_texture(i ? &target[0]->get_target_texture(RENDER_COLOR) : &src, nearest_sampler.get()); + renderer.set_texture("source", (i ? &target[0]->get_target_texture(RENDER_COLOR) : &src), &nearest_sampler); renderer.add_shader_data(blur_shdata[i]); - quad->draw(renderer); + quad.draw(renderer); } - combine_texturing.attach(0, src, nearest_sampler.get()); - renderer.set_texturing(&combine_texturing); + renderer.set_texture("source", &src, &nearest_sampler); + renderer.set_texture("blurred", &target[1]->get_target_texture(RENDER_COLOR), &linear_sampler); renderer.set_shader_program(&combine_shader); - quad->draw(renderer); + quad.draw(renderer); } @@ -92,9 +88,9 @@ Bloom::Template::Template(): strength(0.2f) { } -Bloom *Bloom::Template::create(unsigned width, unsigned height) const +Bloom *Bloom::Template::create(Resources &res, unsigned width, unsigned height) const { - RefPtr bloom = new Bloom(width/size_divisor, height/size_divisor); + RefPtr bloom = new Bloom(res, width/size_divisor, height/size_divisor); bloom->set_radius(radius); bloom->set_strength(strength); return bloom.release();