From 7252ba78416426809459c432f427c814a99d2878 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sat, 16 Sep 2017 17:47:40 -0600 Subject: [PATCH] light: hack -soft to give better results on https://github.com/ericwa/tyrutils-ericw/issues/171 --- light/ltface.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/light/ltface.cc b/light/ltface.cc index c17c281e..7a6fb65e 100644 --- a/light/ltface.cc +++ b/light/ltface.cc @@ -2540,14 +2540,21 @@ BoxBlurImage(const std::vector &input, int w, int h, int radius) for (int y0 = -radius; y0 <= radius; y0++) { for (int x0 = -radius; x0 <= radius; x0++) { - const int x1 = x + x0; - const int y1 = y + y0; + const int x1 = qclamp(x + x0, 0, w - 1); + const int y1 = qclamp(y + y0, 0, h - 1); // check if the kernel goes outside of the source image + + // 2017-09-16: this is a hack, but clamping the + // x/y instead of discarding the samples outside of the + // kernel looks better in some cases: + // https://github.com/ericwa/tyrutils-ericw/issues/171 +#if 0 if (x1 < 0 || x1 >= w) continue; if (y1 < 0 || y1 >= h) continue; +#endif // read the input sample const float weight = 1.0f;