- int base_texture_size, texture_size;
- if (direction == HORIZONTAL) {
- base_texture_size = texture_size = 1280; // FIXME
- } else if (direction == VERTICAL) {
- base_texture_size = texture_size = 720; // FIXME
- } else {
- assert(false);
- }
-
- // We only have 16 taps to work with on each side, 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.
- //
- // FIXME: we really need to pick the same mipmap level for both horizontal and vertical!
- unsigned base_mipmap_level = 0;
- float adjusted_radius = radius;
- while (texture_size > 1 && adjusted_radius * 2.5f > NUM_TAPS / 2) {
- ++base_mipmap_level;
- texture_size /= 2; // Rounding down.
- adjusted_radius = radius * float(texture_size) / float(base_texture_size);
- }
-
- // In the second pass, we do the same, but don't sample from a mipmap;
- // that would re-blur the other direction in an ugly fashion, and we already
- // have the vertical box blur we need from that pass.
- //
- // TODO: We really need to present horizontal+vertical as a unit;
- // currently, there's really no guarantee vertical blur is the second pass.
- if (direction == VERTICAL) {
- base_mipmap_level = 0;
- }
-
- glActiveTexture(GL_TEXTURE0);
- check_error();
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, base_mipmap_level);
- check_error();
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, base_mipmap_level);
- check_error();
-