diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2019-03-16 17:56:01 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2019-03-16 17:56:01 +0300 |
commit | 4b1dd1ea5fd39e6fe6979755d4e35e4ca978588c (patch) | |
tree | a5d687763c8cd0236f40cf143f88a996b395c948 | |
parent | 41699ae84a7d1f29f4938752c24e61da6c101aa5 (diff) |
glTF expoter: check image sizes when merging images
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py index eb796df6..4f579800 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py @@ -18,8 +18,8 @@ from io_scene_gltf2.blender.exp.gltf2_blender_gather_cache import cached from io_scene_gltf2.io.com import gltf2_io from io_scene_gltf2.blender.exp import gltf2_blender_gather_texture from io_scene_gltf2.blender.exp import gltf2_blender_search_node_tree -from io_scene_gltf2.blender.exp import gltf2_blender_export_keys from io_scene_gltf2.blender.exp import gltf2_blender_get +from io_scene_gltf2.io.com.gltf2_io_debug import print_console from io_scene_gltf2.io.com.gltf2_io_extensions import Extension @@ -49,6 +49,20 @@ def __filter_texture_info(blender_shader_sockets_or_texture_slots, export_settin if any([__get_tex_from_socket(socket) is None for socket in blender_shader_sockets_or_texture_slots]): # sockets do not lead to a texture --> discard return False + + resolution = __get_tex_from_socket(blender_shader_sockets_or_texture_slots[0]).shader_node.image.size + if any(__get_tex_from_socket(elem).shader_node.image.size != resolution + for elem in blender_shader_sockets_or_texture_slots): + def format_image(image_node): + return "{} ({}x{})".format(image_node.name, image_node.image.size[0], image_node.image.size[1]) + + images = [format_image(__get_tex_from_socket(elem).shader_node) for elem in + blender_shader_sockets_or_texture_slots] + + print_console("ERROR", "Image sizes do not match. In order to be merged into one image file, " + "images need to be of the same size. Images: {}".format(images)) + return False + return True |