From: Steinar H. Gunderson Date: Thu, 5 Jul 2018 22:45:53 +0000 (+0200) Subject: Reject motion search if we go beyond the image boundary; seems to fix most of the... X-Git-Tag: 1.8.0~76^2~240 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=9cc95703513b137c304514f09867aea4c869748b;p=nageru Reject motion search if we go beyond the image boundary; seems to fix most of the bad edge behavior. --- diff --git a/motion_search.frag b/motion_search.frag index a417834..262dca5 100644 --- a/motion_search.frag +++ b/motion_search.frag @@ -137,8 +137,14 @@ void main() u -= (H_inv * du) * inv_image_size; } - // Reject if we moved too far. - if (length((u - initial_u) * image_size) > patch_size) { + // Reject if we moved too far. Also reject if the patch goes out-of-bounds + // (the paper does not mention this, but the code does, and it seems to be + // critical to avoid really bad behavior at the edges). + if ((length((u - initial_u) * image_size) > patch_size) || + u.x * image_size.x < -(patch_size * 0.5f) || + (1.0 - u.x) * image_size.x < -(patch_size * 0.5f) || + u.y * image_size.y < -(patch_size * 0.5f) || + (1.0 - u.y) * image_size.y < -(patch_size * 0.5f)) { u = initial_u; }