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>2018-12-18 23:31:29 +0300
committerJulien Duroure <julien.duroure@gmail.com>2018-12-18 23:31:29 +0300
commitbf867f50228505710c51eb7d76832415c36d9f74 (patch)
tree0bff37b29027c65fd0dcd9f333772c2619f80532 /io_scene_gltf2/blender/exp/gltf2_blender_get.py
parent9aa6c8058b32675b2636632d6735f66baf6300b1 (diff)
glTF exporter: various fixes & enhancement
* Fix some Yup conversions * reading material from glTF node group material if exists * Fix normal export * Round transforms near 0 and 1 * Fix exporting from Edit mode * Various image format management
Diffstat (limited to 'io_scene_gltf2/blender/exp/gltf2_blender_get.py')
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_get.py34
1 files changed, 26 insertions, 8 deletions
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_get.py b/io_scene_gltf2/blender/exp/gltf2_blender_get.py
index 6d025980..7801190b 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_get.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_get.py
@@ -43,20 +43,38 @@ def get_socket_or_texture_slot(blender_material: bpy.types.Material, name: str):
:return: either a blender NodeSocket, if the material is a node tree or a blender Texture otherwise
"""
if blender_material.node_tree and blender_material.use_nodes:
- i = [input for input in blender_material.node_tree.inputs]
- o = [output for output in blender_material.node_tree.outputs]
- nodes = [node for node in blender_material.node_tree.nodes]
+ #i = [input for input in blender_material.node_tree.inputs]
+ #o = [output for output in blender_material.node_tree.outputs]
if name == "Emissive":
- nodes = filter(lambda n: isinstance(n, bpy.types.ShaderNodeEmission), nodes)
+ type = bpy.types.ShaderNodeEmission
name = "Color"
else:
- nodes = filter(lambda n: isinstance(n, bpy.types.ShaderNodeBsdfPrincipled), nodes)
+ type = bpy.types.ShaderNodeBsdfPrincipled
+ nodes = [n for n in blender_material.node_tree.nodes if isinstance(n, type)]
inputs = sum([[input for input in node.inputs if input.name == name] for node in nodes], [])
- if not inputs:
- return None
- return inputs[0]
+ if inputs:
+ return inputs[0]
+
+ return None
+
+
+def get_socket_or_texture_slot_old(blender_material: bpy.types.Material, name: str):
+ """
+ For a given material input name, retrieve the corresponding node tree socket in the special glTF Metallic Roughness nodes (which might be deprecated?).
+
+ :param blender_material: a blender material for which to get the socket/slot
+ :param name: the name of the socket/slot
+ :return: either a blender NodeSocket, if the material is a node tree or a blender Texture otherwise
+ """
+ if blender_material.node_tree and blender_material.use_nodes:
+ nodes = [n for n in blender_material.node_tree.nodes if \
+ isinstance(n, bpy.types.ShaderNodeGroup) and \
+ n.node_tree.name.startswith('glTF Metallic Roughness')]
+ inputs = sum([[input for input in node.inputs if input.name == name] for node in nodes], [])
+ if inputs:
+ return inputs[0]
return None