Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2381 #2392

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions addons/io_scene_gltf2/blender/exp/material/encode_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,16 @@ def blender_image(self, export_settings) -> Optional[bpy.types.Image]:

for fill in self.fills.values():
return fill.image

if self.__on_happy_path_udim():
# Store that this image is fully exported (used to export or not not used images)
for fill in self.fills.values():
export_settings['exported_images'][fill.image.name] = 1 # Fully used
break

for fill in self.fills.values():
return fill.image

return None

def __on_happy_path(self) -> bool:
Expand Down Expand Up @@ -431,6 +441,8 @@ def __encode_from_image_tile(self, udim_image, tile, export_settings):
return data

# We don't manage UDIM packed image, so this could not happen to be here
# Lets display an error
export_settings['log'].error("UDIM packed images are not supported for export. Please unpack them before exporting.")


def _encode_temp_image(tmp_image: bpy.types.Image, file_format: str, export_settings) -> bytes:
Expand Down
4 changes: 2 additions & 2 deletions addons/io_scene_gltf2/blender/exp/material/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def __get_image_data_grayscale_anisotropy(sockets, results, export_settings) ->


def __is_blender_image_a_jpeg(image: bpy.types.Image) -> bool:
if image.source != 'FILE':
if image.source not in ['FILE', 'TILED']:
return False
if image.filepath_raw == '' and image.packed_file:
return image.packed_file.data[:3] == b'\xff\xd8\xff'
Expand All @@ -432,7 +432,7 @@ def __is_blender_image_a_jpeg(image: bpy.types.Image) -> bool:


def __is_blender_image_a_webp(image: bpy.types.Image) -> bool:
if image.source != 'FILE':
if image.source not in ['FILE', 'TILED']:
return False
if image.filepath_raw == '' and image.packed_file:
return image.packed_file.data[8:12] == b'WEBP'
Expand Down
4 changes: 4 additions & 0 deletions addons/io_scene_gltf2/blender/exp/primitive_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,10 @@ def manage_material_info(self):
indices = np.where((self.dots[uvmap_name + '0'] >= u) & (self.dots[uvmap_name + '0'] <= (u + 1)) & (
self.dots[uvmap_name + '1'] <= (1 - v)) & (self.dots[uvmap_name + '1'] >= 1 - (v + 1)))[0]

# If no vertex in this tile, continue
if indices.shape[0] == 0:
continue

# Reset UVMap to 0-1 : reset to Blener UVMAP => slide to 0-1 => go to glTF UVMap
self.dots[uvmap_name + '1'][indices] -= 1
self.dots[uvmap_name + '1'][indices] *= -1
Expand Down
Loading