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.
This commit is contained in:
lawnjelly 2021-03-11 10:30:21 +00:00
parent 9952a5039a
commit 9b6742346b

View file

@ -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;
}