- //glActiveTexture(GL_TEXTURE0);
- //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 3);
- //check_error();
-
- set_uniform_float(glsl_program_num, prefix, "pixel_offset", 1.0f / 1280.0f); // FIXME
+ // We only have 15 taps to work with, and we want that to reach out to about 2.5*sigma.
+ // Bump up the mipmap levels (giving us box blurs) until we have what we need.
+ unsigned base_mipmap_level = 0;
+ float adjusted_radius = radius;
+ float pixel_size = 1.0f;
+ while (adjusted_radius * 2.5f > 7.0f) {
+ ++base_mipmap_level;
+ adjusted_radius *= 0.5f;
+ pixel_size *= 2.0f;
+ }
+
+ glActiveTexture(GL_TEXTURE0);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, base_mipmap_level);
+ check_error();
+
+ set_uniform_float(glsl_program_num, prefix, "pixel_offset", pixel_size / 1280.0f); // FIXME