diff options
Diffstat (limited to 'io_scene_gltf2/blender')
3 files changed, 23 insertions, 8 deletions
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_material_normal_texture_info_class.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_material_normal_texture_info_class.py index a2480787..ee948ff2 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_material_normal_texture_info_class.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_material_normal_texture_info_class.py @@ -57,15 +57,13 @@ def __filter_texture_info(blender_shader_sockets_or_texture_slots, export_settin def __gather_extensions(blender_shader_sockets_or_texture_slots, export_settings): - normal_map_node = blender_shader_sockets_or_texture_slots[0].links[0].from_node - if not isinstance(normal_map_node, bpy.types.ShaderNodeNormalMap): + if not hasattr(blender_shader_sockets_or_texture_slots[0], 'links'): return None - texture_socket = normal_map_node.inputs["Color"] - if len(texture_socket.links) == 0: + tex_nodes = [__get_tex_from_socket(socket).shader_node for socket in blender_shader_sockets_or_texture_slots] + texture_node = tex_nodes[0] if (tex_nodes is not None and len(tex_nodes) > 0) else None + if texture_node is None: return None - - texture_node = texture_socket.links[0].from_node texture_transform = gltf2_blender_get.get_texture_transform_from_texture_node(texture_node) if texture_transform is None: return None diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_material_occlusion_texture_info_class.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_material_occlusion_texture_info_class.py index 6fb543c0..4c4297ce 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_material_occlusion_texture_info_class.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_material_occlusion_texture_info_class.py @@ -18,6 +18,8 @@ from io_scene_gltf2.blender.exp.gltf2_blender_gather_cache import cached from io_scene_gltf2.io.com import gltf2_io from io_scene_gltf2.blender.exp import gltf2_blender_gather_texture from io_scene_gltf2.blender.exp import gltf2_blender_search_node_tree +from io_scene_gltf2.blender.exp import gltf2_blender_get +from io_scene_gltf2.io.com.gltf2_io_extensions import Extension @cached @@ -54,7 +56,19 @@ def __filter_texture_info(blender_shader_sockets_or_texture_slots, export_settin def __gather_extensions(blender_shader_sockets_or_texture_slots, export_settings): - return None + if not hasattr(blender_shader_sockets_or_texture_slots[0], 'links'): + return None + + tex_nodes = [__get_tex_from_socket(socket).shader_node for socket in blender_shader_sockets_or_texture_slots] + texture_node = tex_nodes[0] if (tex_nodes is not None and len(tex_nodes) > 0) else None + if texture_node is None: + return None + texture_transform = gltf2_blender_get.get_texture_transform_from_texture_node(texture_node) + if texture_transform is None: + return None + + extension = Extension("KHR_texture_transform", texture_transform) + return {"KHR_texture_transform": extension} def __gather_extras(blender_shader_sockets_or_texture_slots, export_settings): diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py index 9a713062..124c8ba0 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py @@ -73,7 +73,10 @@ def __gather_extensions(blender_shader_sockets_or_texture_slots, export_settings if not hasattr(blender_shader_sockets_or_texture_slots[0], 'links'): return None - texture_node = blender_shader_sockets_or_texture_slots[0].links[0].from_node + tex_nodes = [__get_tex_from_socket(socket).shader_node for socket in blender_shader_sockets_or_texture_slots] + texture_node = tex_nodes[0] if (tex_nodes is not None and len(tex_nodes) > 0) else None + if texture_node is None: + return None texture_transform = gltf2_blender_get.get_texture_transform_from_texture_node(texture_node) if texture_transform is None: return None |