diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2019-04-20 00:06:18 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2019-04-20 00:06:18 +0300 |
commit | e49613a5f9c879b1b525e8ac3e3c8af31c3eabcd (patch) | |
tree | d8e799111a5878e86eff2906daeb45d513e02446 /io_scene_gltf2/blender/exp/gltf2_blender_get.py | |
parent | e4165cee8b34b216db5ff41b20b9a05991a4b4b7 (diff) |
glTF: better occlusion map management
At import, create a node group where you can link an image texture
At export, use this node group to create correctly the material
TODO: doc update
Diffstat (limited to 'io_scene_gltf2/blender/exp/gltf2_blender_get.py')
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_get.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_get.py b/io_scene_gltf2/blender/exp/gltf2_blender_get.py index 27d8a341..fef2e684 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_get.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_get.py @@ -15,6 +15,7 @@ import bpy from mathutils import Vector, Matrix +from ..com.gltf2_blender_material_helpers import get_gltf_node_name from ...blender.com.gltf2_blender_conversion import texture_transform_blender_to_gltf from io_scene_gltf2.io.com import gltf2_io_debug @@ -73,16 +74,17 @@ def get_socket_or_texture_slot(blender_material: bpy.types.Material, name: str): 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?). + For a given material input name, retrieve the corresponding node tree socket in the special glTF node group. :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 """ + gltf_node_group_name = get_gltf_node_name().lower() 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')] + (n.node_tree.name.startswith('glTF Metallic Roughness') or n.node_tree.name.lower() == gltf_node_group_name)] inputs = sum([[input for input in node.inputs if input.name == name] for node in nodes], []) if inputs: return inputs[0] |