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-01-03 00:43:32 +0300
committerJulien Duroure <julien.duroure@gmail.com>2019-01-03 00:43:32 +0300
commit8e2f670bc2fe42b98f4c425ee8a5839f0227f2cc (patch)
tree91feb92fa4f914b59158e609a9e6cb2d1ea95611 /io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py
parent06d30213f0cc2246acea9d80073e8105f3ba6685 (diff)
glTF exporter: various fixes/enhancements:
* enhancement for vertex weights export * export animation only if checkbox is ticked * use unsigned short or unsigned int for indices * Fix T60012 metallic and roughness image export (channels not in same image)
Diffstat (limited to 'io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py')
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_image.py33
1 files changed, 26 insertions, 7 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 b6131a59..a694cac3 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py
@@ -115,20 +115,35 @@ def __get_image_data(sockets_or_slots, export_settings):
image = None
for result, socket in zip(results, sockets_or_slots):
# rudimentarily try follow the node tree to find the correct image data.
- channel = None
+ source_channel = None
+ target_channel = None
+ source_channels_length = None
for elem in result.path:
if isinstance(elem.from_node, bpy.types.ShaderNodeSeparateRGB):
- channel = {
+ source_channel = {
'R': 0,
'G': 1,
'B': 2
}[elem.from_socket.name]
- if channel is not None:
- pixels = [split_pixels_by_channels(result.shader_node.image, export_settings)[channel]]
+ if source_channel is not None:
+ pixels = [split_pixels_by_channels(result.shader_node.image, export_settings)[source_channel]]
+ target_channel = source_channel
+ source_channel = 0
+ source_channels_length = 1
else:
pixels = split_pixels_by_channels(result.shader_node.image, export_settings)
- channel = 0
+ target_channel = 0
+ source_channel = 0
+ source_channels_length = len(pixels)
+
+ # Change target channel for metallic and roughness.
+ if elem.to_socket.name == 'Metallic':
+ target_channel = 2
+ source_channels_length = 1
+ elif elem.to_socket.name == 'Roughness':
+ target_channel = 1
+ source_channels_length = 1
file_name = os.path.splitext(result.shader_node.image.name)[0]
@@ -137,13 +152,15 @@ def __get_image_data(sockets_or_slots, export_settings):
result.shader_node.image.filepath,
result.shader_node.image.size[0],
result.shader_node.image.size[1],
- channel,
+ source_channel,
+ target_channel,
+ source_channels_length,
pixels)
if image is None:
image = image_data
else:
- image.add_to_image(channel, image_data)
+ image.add_to_image(target_channel, image_data)
return image
elif __is_slot(sockets_or_slots):
@@ -156,6 +173,8 @@ def __get_image_data(sockets_or_slots, export_settings):
texture.image.size[0],
texture.image.size[1],
0,
+ 0,
+ len(pixels),
pixels)
return image_data
else: