[Bf-extensions-cvs] [5f2cb885] master: glTF exporter: fix export when texture is used only for alpha

Julien Duroure noreply at git.blender.org
Mon Nov 30 18:45:52 CET 2020


Commit: 5f2cb885abb90e5c0c44c3ff699502d2bc14fca9
Author: Julien Duroure
Date:   Mon Nov 30 18:45:29 2020 +0100
Branches: master
https://developer.blender.org/rBA5f2cb885abb90e5c0c44c3ff699502d2bc14fca9

glTF exporter: fix export when texture is used only for alpha

===================================================================

M	io_scene_gltf2/__init__.py
M	io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py
M	io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py

===================================================================

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):



More information about the Bf-extensions-cvs mailing list