Skip to content

Commit

Permalink
Merge pull request #2359 from KhronosGroup/fix_2325_2319
Browse files Browse the repository at this point in the history
  • Loading branch information
julienduroure authored Sep 26, 2024
2 parents 11f9aef + f0616ca commit 50d68b0
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions addons/io_scene_gltf2/blender/exp/primitive_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,6 @@ def manage_material_info(self):
materials_use_vc = None
warning_already_displayed = False
warning_already_displayed_vc_nodetree = False
some_alpha = False
for material_idx in self.prim_indices.keys():
base_material, material_info = get_base_material(material_idx, self.materials, self.export_settings)

Expand Down Expand Up @@ -520,8 +519,6 @@ def manage_material_info(self):
elif materials_use_vc is None:
materials_use_vc = vc_key
add_alpha = True # As we are using the active Vertex Color without checking node tree, we need to add alpha
if add_alpha is True:
some_alpha = True
self.vc_infos.append({
'color': vc_color_name,
'alpha': vc_alpha_name,
Expand Down Expand Up @@ -577,8 +574,6 @@ def manage_material_info(self):
materials_use_vc = vc_key
add_alpha = vc_alpha_name is not None
add_alpha = add_alpha and material_info['vc_info']['alpha_mode'] != "OPAQUE"
if add_alpha is True:
some_alpha = True
self.vc_infos.append({
'color': vc_color_name,
'alpha': vc_alpha_name,
Expand Down Expand Up @@ -757,7 +752,7 @@ def manage_material_info(self):
if no_materials is False or (no_materials is True and self.export_settings['gltf_active_vertex_color_when_no_material'] is True):
for vc in self.blender_mesh.color_attributes:
if vc.name not in [v['color'] for v in self.vc_infos if v['forced'] is False]:
add_alpha = some_alpha is True
add_alpha = True # As we are using the active Vertex Color without checking node tree, we need to add alpha
self.vc_infos.append({
'color': vc.name,
'alpha': vc.name,
Expand Down Expand Up @@ -940,8 +935,11 @@ def primitive_creation_edges_and_points(self):
self.attributes_edges_points[attr['gltf_attribute_name']] = {}
self.attributes_edges_points[attr['gltf_attribute_name']]["data"] = res
self.attributes_edges_points[attr['gltf_attribute_name']]["component_type"] = gltf2_blender_conversion.get_component_type(attr['blender_data_type'])
self.attributes_edges_points[attr['gltf_attribute_name']]["data_type"] = gltf2_blender_conversion.get_data_type(attr['blender_data_type'])

if attr['gltf_attribute_name'].startswith('COLOR_'):
# Because we can have remove the alpha channel, we need to check the length of the data, and not be based on the Blender data type
self.attributes_edges_points[attr['gltf_attribute_name']]["data_type"] = gltf2_io_constants.DataType.Vec3 if attr['len'] == 3 else gltf2_io_constants.DataType.Vec4
else:
self.attributes_edges_points[attr['gltf_attribute_name']]["data_type"] = gltf2_blender_conversion.get_data_type(attr['blender_data_type'])

if self.skin:
joints = [[] for _ in range(self.num_joint_sets)]
Expand Down Expand Up @@ -989,8 +987,11 @@ def primitive_creation_edges_and_points(self):
self.attributes_edges_points[attr['gltf_attribute_name']] = {}
self.attributes_edges_points[attr['gltf_attribute_name']]["data"] = res
self.attributes_edges_points[attr['gltf_attribute_name']]["component_type"] = gltf2_blender_conversion.get_component_type(attr['blender_data_type'])
self.attributes_edges_points[attr['gltf_attribute_name']]["data_type"] = gltf2_blender_conversion.get_data_type(attr['blender_data_type'])

if attr['gltf_attribute_name'].startswith('COLOR_'):
# Because we can have remove the alpha channel, we need to check the length of the data, and not be based on the Blender data type
self.attributes_edges_points[attr['gltf_attribute_name']]["data_type"] = gltf2_io_constants.DataType.Vec3 if attr['len'] == 3 else gltf2_io_constants.DataType.Vec4
else:
self.attributes_edges_points[attr['gltf_attribute_name']]["data_type"] = gltf2_blender_conversion.get_data_type(attr['blender_data_type'])

if self.skin:
joints = [[] for _ in range(self.num_joint_sets)]
Expand Down

0 comments on commit 50d68b0

Please sign in to comment.