X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=blur_effect.cpp;h=adffe089a6d452d5f06a2c9907710aa152ee1f6f;hp=2084768bc54393985bbfccdf48f0be1f10741f08;hb=1bd97eb70a6fcb913bf954e369bc1a90ba17f74e;hpb=419bbfe5e46add3df115882dbf489ccfe080d2f9 diff --git a/blur_effect.cpp b/blur_effect.cpp index 2084768..adffe08 100644 --- a/blur_effect.cpp +++ b/blur_effect.cpp @@ -6,6 +6,7 @@ #include "blur_effect.h" #include "effect_chain.h" #include "effect_util.h" +#include "init.h" #include "util.h" using namespace std; @@ -189,24 +190,27 @@ void SingleBlurPassEffect::set_gl_state(GLuint glsl_program_num, const string &p uniform_samples[2 * 0 + 0] = 0.0f; uniform_samples[2 * 0 + 1] = weight[0]; + int size; + if (direction == HORIZONTAL) { + size = width; + } else if (direction == VERTICAL) { + size = height; + } else { + assert(false); + } + float num_subtexels = size / movit_texel_subpixel_precision; + float inv_num_subtexels = movit_texel_subpixel_precision / size; + // All other samples. for (int i = 1; i < num_taps / 2 + 1; ++i) { unsigned base_pos = i * 2 - 1; float w1 = weight[base_pos]; float w2 = weight[base_pos + 1]; - int size; - if (direction == HORIZONTAL) { - size = width; - } else if (direction == VERTICAL) { - size = height; - } else { - assert(false); - } float pos1 = base_pos / (float)size; float pos2 = (base_pos + 1) / (float)size; float pos, total_weight; - combine_two_samples(w1, w2, pos1, pos2, size, &pos, &total_weight, NULL); + combine_two_samples(w1, w2, pos1, pos2, num_subtexels, inv_num_subtexels, &pos, &total_weight, NULL); uniform_samples[2 * i + 0] = pos; uniform_samples[2 * i + 1] = total_weight;