diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2020-11-30 20:45:29 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2020-11-30 20:45:29 +0300 |
commit | 5f2cb885abb90e5c0c44c3ff699502d2bc14fca9 (patch) | |
tree | dcad84b0fb6594a49571db31b9be0ea2c4a6944e | |
parent | ce3a7fc885a0a26c570e8f4a9f9de8a0806cab01 (diff) |
glTF exporter: fix export when texture is used only for alpha
3 files changed, 11 insertions, 7 deletions
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py index 37f79ca5..966347d0 100755 --- a/io_scene_gltf2/__init__.py +++ b/io_scene_gltf2/__init__.py @@ -15,7 +15,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": (1, 5, 2), + "version": (1, 5, 3), 'blender': (2, 91, 0), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py index 7c1fa861..bb7621ed 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py @@ -182,7 +182,7 @@ def __get_image_data(sockets, export_settings) -> ExportImage: dst_chan = Channel.G elif socket.name == 'Occlusion': dst_chan = Channel.R - elif socket.name == 'Alpha' and len(sockets) > 1 and sockets[1] is not None: + elif socket.name == 'Alpha': dst_chan = Channel.A elif socket.name == 'Clearcoat': dst_chan = Channel.R diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py index a6a28fc4..5b3c1bc6 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py @@ -81,12 +81,16 @@ def __gather_base_color_texture(blender_material, export_settings): base_color_socket = gltf2_blender_get.get_socket_old(blender_material, "BaseColor") alpha_socket = gltf2_blender_get.get_socket(blender_material, "Alpha") - if alpha_socket is not None and alpha_socket.is_linked: - inputs = (base_color_socket, alpha_socket, ) - else: - inputs = (base_color_socket,) - return gltf2_blender_gather_texture_info.gather_texture_info(base_color_socket, inputs, export_settings) + # keep sockets that have some texture : color and/or alpha + inputs = tuple( + socket for socket in [base_color_socket, alpha_socket] + if socket is not None and __has_image_node_from_socket(socket) + ) + if not inputs: + return None + + return gltf2_blender_gather_texture_info.gather_texture_info(inputs[0], inputs, export_settings) def __gather_extensions(blender_material, export_settings): |