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>2020-11-30 20:47:05 +0300
committerJulien Duroure <julien.duroure@gmail.com>2020-11-30 20:47:05 +0300
commit5088c8d9d735a7fe91cd187d03d3afcb795bd6fa (patch)
tree77aa15aaacb4114290311fddfceff61b5aea7015 /io_scene_gltf2
parent5f2cb885abb90e5c0c44c3ff699502d2bc14fca9 (diff)
glTF exporter: take care of active output node
Diffstat (limited to 'io_scene_gltf2')
-rwxr-xr-xio_scene_gltf2/__init__.py2
-rw-r--r--io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_unlit.py2
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_get.py13
3 files changed, 15 insertions, 2 deletions
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 966347d0..4cf7b207 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, 3),
+ "version": (1, 5, 4),
'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_materials_unlit.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_unlit.py
index b3012ea0..f000bb56 100644
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_unlit.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_unlit.py
@@ -38,7 +38,7 @@ def detect_shadeless_material(blender_material, export_settings):
info = {}
for node in blender_material.node_tree.nodes:
- if node.type == 'OUTPUT_MATERIAL':
+ if node.type == 'OUTPUT_MATERIAL' and node.is_active_output:
socket = node.inputs[0]
break
else:
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_get.py b/io_scene_gltf2/blender/exp/gltf2_blender_get.py
index 58b835c0..ee63aa7e 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_get.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_get.py
@@ -60,6 +60,7 @@ def get_socket(blender_material: bpy.types.Material, name: str):
type = bpy.types.ShaderNodeEmission
name = "Color"
nodes = [n for n in blender_material.node_tree.nodes if isinstance(n, type) and not n.mute]
+ nodes = [node for node in nodes if check_if_is_linked_to_active_output(node.outputs[0])]
inputs = sum([[input for input in node.inputs if input.name == name] for node in nodes], [])
if inputs:
return inputs[0]
@@ -72,6 +73,7 @@ def get_socket(blender_material: bpy.types.Material, name: str):
else:
type = bpy.types.ShaderNodeBsdfPrincipled
nodes = [n for n in blender_material.node_tree.nodes if isinstance(n, type) and not n.mute]
+ nodes = [node for node in nodes if check_if_is_linked_to_active_output(node.outputs[0])]
inputs = sum([[input for input in node.inputs if input.name == name] for node in nodes], [])
if inputs:
return inputs[0]
@@ -98,6 +100,17 @@ def get_socket_old(blender_material: bpy.types.Material, name: str):
return None
+def check_if_is_linked_to_active_output(shader_socket):
+ for link in shader_socket.links:
+ if isinstance(link.to_node, bpy.types.ShaderNodeOutputMaterial) and link.to_node.is_active_output is True:
+ return True
+
+ if len(link.to_node.outputs) > 0: # ignore non active output, not having output sockets
+ ret = check_if_is_linked_to_active_output(link.to_node.outputs[0]) # recursive until find an output material node
+ if ret is True:
+ return True
+
+ return False
def find_shader_image_from_shader_socket(shader_socket, max_hops=10):
"""Find any ShaderNodeTexImage in the path from the socket."""