[Bf-blender-cvs] [2cd7b80cae6] master: Fix T49570: Cycles baking can't handle materials with no images

Dalai Felinto noreply at git.blender.org
Tue May 30 19:06:56 CEST 2017


Commit: 2cd7b80cae671baa6552dedd980ba131517605e8
Author: Dalai Felinto
Date:   Tue May 30 14:41:21 2017 +0200
Branches: master
https://developer.blender.org/rB2cd7b80cae671baa6552dedd980ba131517605e8

Fix T49570: Cycles baking can't handle materials with no images

If users wanted to bake only a few of the mesh materials, they would
still need to create dummy textures for the other parts.

This commit report (as RPT_INFO) the materials with no texture, but move
on to bake the others materials.

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

M	source/blender/editors/object/object_bake_api.c
M	source/blender/render/intern/source/bake_api.c

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

diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index b059e4f6ca7..ad43c48f0b9 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -414,16 +414,16 @@ static bool bake_object_check(Scene *scene, Object *ob, ReportList *reports)
 		else {
 			Material *mat = give_current_material(ob, i);
 			if (mat != NULL) {
-				BKE_reportf(reports, RPT_ERROR,
+				BKE_reportf(reports, RPT_INFO,
 				            "No active image found in material \"%s\" (%d) for object \"%s\"",
 				            mat->id.name + 2, i, ob->id.name + 2);
 			}
 			else {
-				BKE_reportf(reports, RPT_ERROR,
+				BKE_reportf(reports, RPT_INFO,
 				            "No active image found in material slot (%d) for object \"%s\"",
 				            i, ob->id.name + 2);
 			}
-			return false;
+			continue;
 		}
 
 		image->id.tag |= LIB_TAG_DOIT;
@@ -563,7 +563,11 @@ static void build_image_lookup(Main *bmain, Object *ob, BakeImages *bake_images)
 		Image *image;
 		ED_object_get_active_image(ob, i + 1, &image, NULL, NULL, NULL);
 
-		if ((image->id.tag & LIB_TAG_DOIT)) {
+		/* Some materials have no image, we just ignore those cases. */
+		if (image == NULL) {
+			bake_images->lookup[i] = -1;
+		}
+		else if (image->id.tag & LIB_TAG_DOIT) {
 			for (j = 0; j < i; j++) {
 				if (bake_images->data[j].image == image) {
 					bake_images->lookup[i] = j;
diff --git a/source/blender/render/intern/source/bake_api.c b/source/blender/render/intern/source/bake_api.c
index 73424a4e846..588c327ab91 100644
--- a/source/blender/render/intern/source/bake_api.c
+++ b/source/blender/render/intern/source/bake_api.c
@@ -684,6 +684,10 @@ void RE_bake_pixels_populate(
 		int mat_nr = mp->mat_nr;
 		int image_id = bake_images->lookup[mat_nr];
 
+		if (image_id < 0) {
+			continue;
+		}
+
 		bd.bk_image = &bake_images->data[image_id];
 		bd.primitive_id = ++p_id;




More information about the Bf-blender-cvs mailing list