// box blurs) until we have what we need.
unsigned mipmap_width = input_width, mipmap_height = input_height;
float adjusted_radius = radius;
// box blurs) until we have what we need.
unsigned mipmap_width = input_width, mipmap_height = input_height;
float adjusted_radius = radius;
// Find the next mipmap size (round down, minimum 1 pixel).
mipmap_width = max(mipmap_width / 2, 1u);
mipmap_height = max(mipmap_height / 2, 1u);
// Find the next mipmap size (round down, minimum 1 pixel).
mipmap_width = max(mipmap_width / 2, 1u);
mipmap_height = max(mipmap_height / 2, 1u);
ok |= hpass->set_int("height", mipmap_height);
ok |= hpass->set_int("virtual_width", mipmap_width);
ok |= hpass->set_int("virtual_height", mipmap_height);
ok |= hpass->set_int("height", mipmap_height);
ok |= hpass->set_int("virtual_width", mipmap_width);
ok |= hpass->set_int("virtual_height", mipmap_height);
ok |= vpass->set_float("radius", adjusted_radius);
ok |= vpass->set_int("width", mipmap_width);
ok |= vpass->set_int("height", mipmap_height);
ok |= vpass->set_int("virtual_width", input_width);
ok |= vpass->set_int("virtual_height", input_height);
ok |= vpass->set_float("radius", adjusted_radius);
ok |= vpass->set_int("width", mipmap_width);
ok |= vpass->set_int("height", mipmap_height);
ok |= vpass->set_int("virtual_width", input_width);
ok |= vpass->set_int("virtual_height", input_height);
register_int("height", &height);
register_int("virtual_width", &virtual_width);
register_int("virtual_height", &virtual_height);
register_int("height", &height);
register_int("virtual_width", &virtual_width);
register_int("virtual_height", &virtual_height);
- return read_file("blur_effect.frag");
+ char buf[256];
+ sprintf(buf, "#define DIRECTION_VERTICAL %d\n#define NUM_TAPS %d\n",
+ (direction == VERTICAL), num_taps);
+ return buf + read_file("blur_effect.frag");
}
void SingleBlurPassEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num)
}
void SingleBlurPassEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num)
// Gaussian blur is a common, but maybe not the prettiest choice;
// it can feel a bit too blurry in the fine detail and too little
// long-tail. This is a simple logistic distribution, which has
// Gaussian blur is a common, but maybe not the prettiest choice;
// it can feel a bit too blurry in the fine detail and too little
// long-tail. This is a simple logistic distribution, which has
//
// We pack the parameters into a float4: The relative sample coordinates
// in (x,y), and the weight in z. w is unused.
//
// We pack the parameters into a float4: The relative sample coordinates
// in (x,y), and the weight in z. w is unused.
- samples[4 * 0 + 0] = 0.0f;
- samples[4 * 0 + 1] = 0.0f;
- samples[4 * 0 + 2] = weight[0];
- samples[4 * 0 + 3] = 0.0f;
+ samples[2 * 0 + 0] = 0.0f;
+ samples[2 * 0 + 1] = weight[0];
unsigned base_pos = i * 2 - 1;
float w1 = weight[base_pos];
float w2 = weight[base_pos + 1];
unsigned base_pos = i * 2 - 1;
float w1 = weight[base_pos];
float w2 = weight[base_pos + 1];
float offset, total_weight;
combine_two_samples(w1, w2, &offset, &total_weight, NULL);
float offset, total_weight;
combine_two_samples(w1, w2, &offset, &total_weight, NULL);
- samples[4 * i + 0] = x;
- samples[4 * i + 1] = y;
- samples[4 * i + 2] = total_weight;
- samples[4 * i + 3] = 0.0f;
+ samples[2 * i + 1] = total_weight;
- set_uniform_vec4_array(glsl_program_num, prefix, "samples", samples, NUM_TAPS / 2 + 1);
+ set_uniform_vec2_array(glsl_program_num, prefix, "samples", samples, num_taps / 2 + 1);
+
+ delete[] weight;
+ delete[] samples;