From 9b6742346b2014034ccba97b24af0f5a3c483776 Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Thu, 11 Mar 2021 10:30:21 +0000 Subject: [PATCH] Batching - fix off by one error in light scissoring There have been a couple of reports of pixel lines when using light scissoring. These seem to be an off by one error caused by either rounding or pixel snapping. This PR adds a single pixel boost to light scissor rects to protect against this. This should make little difference to performance. --- drivers/gles_common/rasterizer_canvas_batcher.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gles_common/rasterizer_canvas_batcher.h b/drivers/gles_common/rasterizer_canvas_batcher.h index 0fe00f6a16c..de69e0b0106 100644 --- a/drivers/gles_common/rasterizer_canvas_batcher.h +++ b/drivers/gles_common/rasterizer_canvas_batcher.h @@ -1162,10 +1162,17 @@ PREAMBLE(bool)::_light_scissor_begin(const Rect2 &p_item_rect, const Transform2D int rh = get_storage()->frame.current_rt->height; + // using the exact size was leading to off by one errors, + // possibly due to pixel snap. For this reason we will boost + // the scissor area by 1 pixel, this will take care of any rounding + // issues, and shouldn't significantly negatively impact performance. int y = rh - (cliprect.position.y + cliprect.size.y); + y += 1; // off by 1 boost before flipping + if (get_storage()->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_VFLIP]) y = cliprect.position.y; - get_this()->gl_enable_scissor(cliprect.position.x, y, cliprect.size.width, cliprect.size.height); + + get_this()->gl_enable_scissor(cliprect.position.x - 1, y, cliprect.size.width + 2, cliprect.size.height + 2); return true; }