[Bf-blender-cvs] [10b16ae] blender-v2.72-release: Fix issue reported by Sebastian Koenig on irc, Clone brush would paint trash with float images.

Antony Riakiotakis noreply at git.blender.org
Tue Oct 21 12:14:38 CEST 2014


Commit: 10b16ae2bc4f24c8f44334ede387fe7ec017b515
Author: Antony Riakiotakis
Date:   Fri Oct 17 14:11:13 2014 +0200
Branches: blender-v2.72-release
https://developer.blender.org/rB10b16ae2bc4f24c8f44334ede387fe7ec017b515

Fix issue reported by Sebastian Koenig on irc, Clone brush would paint
trash with float images.

Issue is uninitialized alpha in the clone brush + a clamping issue for
float images. There's still some 'swimming' and brightness issue here
but I have to do work for the weekly, will investigate further later.

===================================================================

M	source/blender/editors/sculpt_paint/paint_image_proj.c
M	source/blender/imbuf/intern/imageprocess.c

===================================================================

diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index f43a2b1..2a6f94a 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -1507,6 +1507,7 @@ static ProjPixel *project_paint_uvpixel_init(
 						project_face_pixel(tf_other, ibuf_other, w, side, NULL, rgba);
 						premul_to_straight_v4(rgba);
 						linearrgb_to_srgb_uchar3(((ProjPixelClone *)projPixel)->clonepx.ch, rgba);
+						((ProjPixelClone *)projPixel)->clonepx.ch[3] =  rgba[3] * 255;
 					}
 					else { /* char to char */
 						project_face_pixel(tf_other, ibuf_other, w, side, ((ProjPixelClone *)projPixel)->clonepx.ch, NULL);
diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c
index cf875bb..8234b01 100644
--- a/source/blender/imbuf/intern/imageprocess.c
+++ b/source/blender/imbuf/intern/imageprocess.c
@@ -166,6 +166,10 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char outI[4],
 	if (x2 >= in->x) x2 = x2 - in->x;
 	if (y2 >= in->y) y2 = y2 - in->y;
 
+	a = u - floorf(u);
+	b = v - floorf(v);
+	a_b = a * b; ma_b = (1.0f - a) * b; a_mb = a * (1.0f - b); ma_mb = (1.0f - a) * (1.0f - b);
+
 	if (outF) {
 		/* sample including outside of edges of image */
 		row1 = in->rect_float + in->x * y1 * 4 + 4 * x1;
@@ -173,14 +177,16 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char outI[4],
 		row3 = in->rect_float + in->x * y1 * 4 + 4 * x2;
 		row4 = in->rect_float + in->x * y2 * 4 + 4 * x2;
 
-		a = u - floorf(u);
-		b = v - floorf(v);
-		a_b = a * b; ma_b = (1.0f - a) * b; a_mb = a * (1.0f - b); ma_mb = (1.0f - a) * (1.0f - b);
-
 		outF[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0];
 		outF[1] = ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1];
 		outF[2] = ma_mb * row1[2] + a_mb * row3[2] + ma_b * row2[2] + a_b * row4[2];
 		outF[3] = ma_mb * row1[3] + a_mb * row3[3] + ma_b * row2[3] + a_b * row4[3];
+
+		/* clamp here or else we can easily get off-range */
+		CLAMP(outF[0], 0.0f, 1.0f);
+		CLAMP(outF[1], 0.0f, 1.0f);
+		CLAMP(outF[2], 0.0f, 1.0f);
+		CLAMP(outF[3], 0.0f, 1.0f);
 	}
 	if (outI) {
 		/* sample including outside of edges of image */
@@ -188,10 +194,6 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char outI[4],
 		row2I = (unsigned char *)in->rect + in->x * y2 * 4 + 4 * x1;
 		row3I = (unsigned char *)in->rect + in->x * y1 * 4 + 4 * x2;
 		row4I = (unsigned char *)in->rect + in->x * y2 * 4 + 4 * x2;
-
-		a = u - floorf(u);
-		b = v - floorf(v);
-		a_b = a * b; ma_b = (1.0f - a) * b; a_mb = a * (1.0f - b); ma_mb = (1.0f - a) * (1.0f - b);
 		
 		/* need to add 0.5 to avoid rounding down (causes darken with the smear brush)
 		 * tested with white images and this should not wrap back to zero */




More information about the Bf-blender-cvs mailing list