[Bf-blender-cvs] [a618c2c] bake-cycles: Cycles-Bake: Support for float formats (openexr, png, ...)

Dalai Felinto noreply at git.blender.org
Wed Apr 23 02:47:32 CEST 2014


Commit: a618c2c5c0d2a52285b9ce661a5026a703603aca
Author: Dalai Felinto
Date:   Wed Mar 19 14:15:30 2014 -0300
https://developer.blender.org/rBa618c2c5c0d2a52285b9ce661a5026a703603aca

Cycles-Bake: Support for float formats (openexr, png, ...)

Next: Support for saving with no alpha

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

M	source/blender/editors/object/object_bake_new.c

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

diff --git a/source/blender/editors/object/object_bake_new.c b/source/blender/editors/object/object_bake_new.c
index 4aeab1b..b58d243 100644
--- a/source/blender/editors/object/object_bake_new.c
+++ b/source/blender/editors/object/object_bake_new.c
@@ -127,15 +127,29 @@ static bool write_external_bake_pixels(
 	ImBuf *ibuf = NULL;
 	short ok = FALSE;
 	ImageFormatData imf;
+	bool is_float;
+
+	is_float = (int) color_depth > 8;
 
 	/* create a new ImBuf */
-	ibuf = IMB_allocImBuf(width, height, color_mode, IB_rect);
+	ibuf = IMB_allocImBuf(width, height, color_mode, (is_float ? IB_rectfloat : IB_rect));
 	if (!ibuf) return false;
 
 	/* populates the ImBuf */
-	IMB_buffer_byte_from_float((unsigned char *) ibuf->rect, buffer, ibuf->channels, ibuf->dither,
-	                           (is_linear?IB_PROFILE_LINEAR_RGB:IB_PROFILE_SRGB), IB_PROFILE_LINEAR_RGB,
-	                           FALSE, ibuf->x, ibuf->y, ibuf->x, ibuf->x);
+	if (is_float) {
+		IMB_buffer_float_from_float(
+		        ibuf->rect_float, buffer, ibuf->channels,
+		        IB_PROFILE_LINEAR_RGB, IB_PROFILE_LINEAR_RGB, false,
+		        ibuf->x, ibuf->y, ibuf->x, ibuf->y
+		        );
+	}
+	else {
+		IMB_buffer_byte_from_float(
+		        (unsigned char *) ibuf->rect, buffer, ibuf->channels, ibuf->dither,
+		        (is_linear?IB_PROFILE_LINEAR_RGB:IB_PROFILE_SRGB), IB_PROFILE_LINEAR_RGB,
+		        false, ibuf->x, ibuf->y, ibuf->x, ibuf->x
+		        );
+	}
 
 	/* setup the ImageFormatData */
 	imf.imtype = imtype;




More information about the Bf-blender-cvs mailing list