From a56922099ef09cf65cea0f7ebade4db99064e145 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 22 Aug 2025 17:08:25 +0200 Subject: [PATCH] ImBuf: Change rounding for byte buffer in IMB_rectfill() It matches the behavior of IMB_rectfill_area() with opaque alpha now. This is important as the function is used in baking, where the neutral 0.5 is expected to be mapped to 128. --- source/blender/imbuf/intern/rectop.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/source/blender/imbuf/intern/rectop.cc b/source/blender/imbuf/intern/rectop.cc index 9561e92b477..c3da06ff5f3 100644 --- a/source/blender/imbuf/intern/rectop.cc +++ b/source/blender/imbuf/intern/rectop.cc @@ -982,12 +982,9 @@ void IMB_rectfill(ImBuf *drect, const float col[4]) if (drect->byte_buffer.data) { uint *rrect = (uint *)drect->byte_buffer.data; - char ccol[4]; - ccol[0] = int(col[0] * 255); - ccol[1] = int(col[1] * 255); - ccol[2] = int(col[2] * 255); - ccol[3] = int(col[3] * 255); + char ccol[4]; + unit_float_to_uchar_clamp_v4(ccol, col); num = IMB_get_pixel_count(drect); for (; num > 0; num--) {