Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Duroure <julien.duroure@gmail.com>2019-08-03 08:18:25 +0300
committerJulien Duroure <julien.duroure@gmail.com>2019-08-03 08:18:25 +0300
commit1e20236039c8929406cf3d86bddcbfd2df5d9a17 (patch)
tree1f903fb7c1fb98988948aedc711e8dde6456ec51 /io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py
parent2c08beb9690cf533badb5535830424a22bf635c9 (diff)
glTF exporter: add alpha export support
Diffstat (limited to 'io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py')
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_image.py14
1 files changed, 11 insertions, 3 deletions
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 07600fcf..a92de291 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py
@@ -91,6 +91,11 @@ def __gather_extras(sockets_or_slots, export_settings):
def __gather_mime_type(sockets_or_slots, export_settings):
+ # force png if Alpha contained so we can export alpha
+ for socket in sockets_or_slots:
+ if socket.name == "Alpha":
+ return "image/png"
+
if export_settings["gltf_image_format"] == "NAME":
extension = __get_extension_from_slot(sockets_or_slots, export_settings)
extension = extension.lower()
@@ -175,13 +180,16 @@ def __get_image_data(sockets_or_slots, export_settings) -> gltf2_blender_image.E
target_channel = None
- # Change target channel for metallic and roughness.
+ # some sockets need channel rewriting (gltf pbr defines fixed channels for some attributes)
if socket.name == 'Metallic':
target_channel = 2
elif socket.name == 'Roughness':
target_channel = 1
elif socket.name == 'Occlusion' and len(sockets_or_slots) > 1 and sockets_or_slots[1] is not None:
target_channel = 0
+ elif socket.name == 'Alpha' and len(sockets_or_slots) > 1 and sockets_or_slots[1] is not None:
+ composed_image.set_alpha(True)
+ target_channel = 3
if target_channel is not None:
if composed_image is None:
@@ -189,8 +197,8 @@ def __get_image_data(sockets_or_slots, export_settings) -> gltf2_blender_image.E
composed_image[target_channel] = image[source_channel]
else:
- # If we're not assigning target channels, just return the first valid image.
- return image
+ # copy full image...eventually following sockets might overwrite things
+ composed_image = image
return composed_image