From 86c04faf7d1504d4d2dde64095c08037d62e15ad Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Wed, 22 Nov 2023 15:35:02 +0100 Subject: [PATCH] Fix #2063 export VC without material --- .../blender/exp/gltf2_blender_gather_primitives_extract.py | 2 +- .../blender/exp/material/gltf2_blender_gather_materials.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py b/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py index 90d28f577..838e0b7a5 100644 --- a/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py +++ b/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py @@ -482,7 +482,7 @@ def manage_material_info(self): # We need to check if we need to add alpha add_alpha = vc_alpha_name is not None mat = get_material_from_idx(material_idx, self.materials, self.export_settings) - add_alpha = add_alpha and not (mat.blend_method is None or mat.blend_method == 'OPAQUE') + add_alpha = mat is not None and add_alpha and not (mat.blend_method is None or mat.blend_method == 'OPAQUE') # Manage Vertex Color (RGB and Alpha if needed) self.__manage_color_attribute(vc_color_name, vc_alpha_name if add_alpha else None) else: diff --git a/addons/io_scene_gltf2/blender/exp/material/gltf2_blender_gather_materials.py b/addons/io_scene_gltf2/blender/exp/material/gltf2_blender_gather_materials.py index 14358ddb2..aa1d3c16e 100644 --- a/addons/io_scene_gltf2/blender/exp/material/gltf2_blender_gather_materials.py +++ b/addons/io_scene_gltf2/blender/exp/material/gltf2_blender_gather_materials.py @@ -555,6 +555,12 @@ def get_base_material(material_idx, materials, export_settings): mat, export_settings ) + + if material is None: + # If no material, the mesh can still have vertex color + # So, retrieving it + material_info["vc_info"] = {"color_type": "active", "alpha_type": "active"} + return material, material_info def get_all_textures(idx=0):