glTF exporter: performance : better way to detect weird images
This commit is contained in:
parent
6e430d2317
commit
cbb4b8c121
|
@ -4,7 +4,7 @@
|
|||
bl_info = {
|
||||
'name': 'glTF 2.0 format',
|
||||
'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
|
||||
"version": (3, 2, 30),
|
||||
"version": (3, 2, 31),
|
||||
'blender': (3, 1, 0),
|
||||
'location': 'File > Import-Export',
|
||||
'description': 'Import-Export as glTF 2.0',
|
||||
|
|
|
@ -181,12 +181,6 @@ def __get_image_data(sockets, export_settings) -> ExportImage:
|
|||
results = [__get_tex_from_socket(socket, export_settings) for socket in sockets]
|
||||
composed_image = ExportImage()
|
||||
for result, socket in zip(results, sockets):
|
||||
if result.shader_node.image.channels == 0:
|
||||
gltf2_io_debug.print_console("WARNING",
|
||||
"Image '{}' has no color channels and cannot be exported.".format(
|
||||
result.shader_node.image))
|
||||
continue
|
||||
|
||||
# Assume that user know what he does, and that channels/images are already combined correctly for pbr
|
||||
# If not, we are going to keep only the first texture found
|
||||
# Example : If user set up 2 or 3 different textures for Metallic / Roughness / Occlusion
|
||||
|
@ -237,6 +231,15 @@ def __get_image_data(sockets, export_settings) -> ExportImage:
|
|||
# copy full image...eventually following sockets might overwrite things
|
||||
composed_image = ExportImage.from_blender_image(result.shader_node.image)
|
||||
|
||||
# Check that we don't have some empty channels (based on weird images without any size for example)
|
||||
keys = list(composed_image.fills.keys()) # do not loop on dict, we may have to delete an element
|
||||
for k in [k for k in keys if isinstance(composed_image.fills[k], FillImage)]:
|
||||
if composed_image.fills[k].image.size[0] == 0 or composed_image.fills[k].image.size[1] == 0:
|
||||
gltf2_io_debug.print_console("WARNING",
|
||||
"Image '{}' has no size and cannot be exported.".format(
|
||||
composed_image.fills[k].image))
|
||||
del composed_image.fills[k]
|
||||
|
||||
return composed_image
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue