blur-effect: Fix the blur filter

Make sure we don't sample the center twice, and don't sample things
that aren't our immediate neighbors.

https://bugzilla.gnome.org/show_bug.cgi?id=683076
This commit is contained in:
Jasper St. Pierre 2012-08-30 21:02:38 -03:00 committed by Emmanuele Bassi
parent fb9e0466c0
commit fd375a7bc9

View File

@ -58,18 +58,15 @@
*/ */
static const gchar *box_blur_glsl_declarations = static const gchar *box_blur_glsl_declarations =
"uniform vec2 pixel_step;\n"; "uniform vec2 pixel_step;\n";
/* FIXME: Is this shader right? It is doing 10 samples (ie, sampling
the middle texel twice) and then only dividing by 9 */
#define SAMPLE(offx, offy) \ #define SAMPLE(offx, offy) \
"cogl_texel += texture2D (cogl_sampler, cogl_tex_coord.st + pixel_step * " \ "cogl_texel += texture2D (cogl_sampler, cogl_tex_coord.st + pixel_step * " \
"vec2 (" G_STRINGIFY (offx) ", " G_STRINGIFY (offy) ") * 2.0);\n" "vec2 (" G_STRINGIFY (offx) ", " G_STRINGIFY (offy) "));\n"
static const gchar *box_blur_glsl_shader = static const gchar *box_blur_glsl_shader =
" cogl_texel = texture2D (cogl_sampler, cogl_tex_coord.st);\n" " cogl_texel = texture2D (cogl_sampler, cogl_tex_coord.st);\n"
SAMPLE (-1.0, -1.0) SAMPLE (-1.0, -1.0)
SAMPLE ( 0.0, -1.0) SAMPLE ( 0.0, -1.0)
SAMPLE (+1.0, -1.0) SAMPLE (+1.0, -1.0)
SAMPLE (-1.0, 0.0) SAMPLE (-1.0, 0.0)
SAMPLE ( 0.0, 0.0)
SAMPLE (+1.0, 0.0) SAMPLE (+1.0, 0.0)
SAMPLE (-1.0, +1.0) SAMPLE (-1.0, +1.0)
SAMPLE ( 0.0, +1.0) SAMPLE ( 0.0, +1.0)