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/blender/exp/gltf2_blender_get.py
parent5f2cb885abb90e5c0c44c3ff699502d2bc14fca9 (diff)
glTF exporter: take care of active output node
Diffstat (limited to 'io_scene_gltf2/blender/exp/gltf2_blender_get.py')
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_get.py13
1 files changed, 13 insertions, 0 deletions
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."""