diff --git a/__init__.py b/__init__.py index 817eec4..0c5a9cc 100644 --- a/__init__.py +++ b/__init__.py @@ -836,11 +836,13 @@ def get_UDIM_image(): for i in range(len(obj.material_slots)): slot = obj.material_slots[i] if slot.material: - nodes = slot.material.node_tree.nodes - if nodes: - for node in nodes: - if node.type == 'TEX_IMAGE' and node.image and node.image.source =='TILED': - return node.image + tree = slot.material.node_tree + if tree: + nodes = tree.nodes + if nodes: + for node in nodes: + if node.type == 'TEX_IMAGE' and node.image and node.image.source =='TILED': + return node.image return None if bpy.context.scene.texToolsSettings.UDIMs_source == 'OBJECT': diff --git a/op_bake.py b/op_bake.py index 7b5ec47..6096ed7 100644 --- a/op_bake.py +++ b/op_bake.py @@ -87,7 +87,7 @@ def poll(cls, context): settings.bake_error = "" return True - if modes[bake_mode].material == "": + if modes[bake_mode].setVColor or not modes[bake_mode].material: def is_bakeable(obj): if len(obj.data.materials) <= 0: # There are no material slots settings.bake_error = "Materials needed" @@ -113,16 +113,33 @@ def is_bakeable(obj): # return False settings.bake_error = "" return True - + + def is_vc_ready(obj): + if len(obj.data.vertex_colors) > 7: + settings.bake_error = "An empty VC layer needed" + return False + settings.bake_error = "" + return True + for bset in settings.sets: if (len(bset.objects_high) + len(bset.objects_float)) == 0: - for obj in bset.objects_low: - if not is_bakeable(obj): - return False + if not modes[bake_mode].material: + for obj in bset.objects_low: + if not is_bakeable(obj): + return False + if modes[bake_mode].setVColor: + for obj in bset.objects_low: + if not is_vc_ready(obj): + return False else: - for obj in (bset.objects_high+bset.objects_float): - if not is_bakeable(obj): - return False + if not modes[bake_mode].material: + for obj in (bset.objects_high + bset.objects_float): + if not is_bakeable(obj): + return False + if modes[bake_mode].setVColor: + for obj in (bset.objects_high + bset.objects_float): + if not is_vc_ready(obj): + return False settings.bake_error = "" return True