Skip to content

Commit

Permalink
Fix jpg & webp detection for udim textures
Browse files Browse the repository at this point in the history
  • Loading branch information
julienduroure committed Oct 31, 2024
1 parent 32a083b commit 0415298
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
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

0 comments on commit 0415298

Please sign in to comment.