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-05-31 08:25:56 +0300
committerJulien Duroure <julien.duroure@gmail.com>2019-05-31 08:25:56 +0300
commitb2b97906fbe0f7930e1afc3d86bd64bc932b1d48 (patch)
tree8808231eba162359149b9e63508b699ef7b72945 /io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py
parent2bbd76ce994615b918de2866953ff50ade072261 (diff)
glTF exporter: Fix T64760, T65234: preserve alpha when exists, and image exporting enhancements
Diffstat (limited to 'io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py')
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_image.py18
1 files changed, 12 insertions, 6 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 5254bc64..07600fcf 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py
@@ -173,18 +173,24 @@ def __get_image_data(sockets_or_slots, export_settings) -> gltf2_blender_image.E
image = gltf2_blender_image.ExportImage.from_blender_image(result.shader_node.image)
- if composed_image is None:
- composed_image = gltf2_blender_image.ExportImage.white_image(image.width, image.height)
+ target_channel = None
# Change target channel for metallic and roughness.
if socket.name == 'Metallic':
- composed_image[2] = image[source_channel]
+ target_channel = 2
elif socket.name == 'Roughness':
- composed_image[1] = image[source_channel]
+ target_channel = 1
elif socket.name == 'Occlusion' and len(sockets_or_slots) > 1 and sockets_or_slots[1] is not None:
- composed_image[0] = image[source_channel]
+ target_channel = 0
+
+ if target_channel is not None:
+ if composed_image is None:
+ composed_image = gltf2_blender_image.ExportImage.white_image(image.width, image.height)
+
+ composed_image[target_channel] = image[source_channel]
else:
- composed_image.update(image)
+ # If we're not assigning target channels, just return the first valid image.
+ return image
return composed_image