"void main()\n"
"{\n"
" gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n"
- " for(int i=-size; i<=size; ++i)\n"
- " gl_FragColor += texture2D(source, texcoord+delta*i)*factors[i+size];\n"
+ " for(int i=0; i<=size*2; ++i)\n"
+ " gl_FragColor += texture2D(source, texcoord+delta*float(i-size))*factors[i];\n"
"}";
static const char combine_vs[]=
combine_shdata.uniform(combine_shader.get_uniform_location("source"), 1);
combine_shdata.uniform(combine_shader.get_uniform_location("blurred"), 0);
+ combine_texturing.attach(0, tex[1]);
+
set_radius(2.0f);
set_strength(0.2f);
MeshBuilder mbld(quad);
- mbld.begin(QUADS);
+ mbld.begin(TRIANGLE_STRIP);
+ mbld.vertex(0, 1);
mbld.vertex(0, 0);
- mbld.vertex(1, 0);
mbld.vertex(1, 1);
- mbld.vertex(0, 1);
+ mbld.vertex(1, 0);
mbld.end();
}
void Bloom::render(const Texture2D &src, const Texture2D &)
{
- const Framebuffer *dest = Framebuffer::current();
- blur_shader.bind();
- fbo.bind();
- src.bind_to(0);
Bind unbind_dtest(static_cast<DepthTest *>(0), true);
Bind unbind_blend(static_cast<Blend *>(0), true);
- for(unsigned i=0; i<2; ++i)
+
{
- fbo.attach(COLOR_ATTACHMENT0, tex[i], 0);
- blur_shdata[i].apply();
- quad.draw();
- tex[i].bind_to(0);
+ Bind bind_shader(blur_shader);
+ Bind bind_fbo(fbo, true);
+ for(unsigned i=0; i<2; ++i)
+ {
+ Bind bind_tex(i ? tex[0] : src);
+ fbo.attach(COLOR_ATTACHMENT0, tex[i], 0);
+ blur_shdata[i].apply();
+ quad.draw();
+ }
}
- if(dest)
- dest->bind();
- else
- Framebuffer::unbind();
-
- combine_shader.bind();
+ combine_texturing.attach(1, src);
+ Bind bind_texturing(combine_texturing);
+ Bind bind_shader(combine_shader);
combine_shdata.apply();
- src.bind_to(1);
quad.draw();
- Program::unbind();
- Texture::unbind_from(1);
- Texture::unbind_from(0);
}
} // namespace GL