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:
Diffstat (limited to 'io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py')
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py44
1 files changed, 28 insertions, 16 deletions
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 15b101ad..5fe2da32 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
@@ -19,14 +19,14 @@ from io_scene_gltf2.io.exp.gltf2_io_user_extensions import export_user_extension
# occlusion the primary_socket would be the occlusion socket, and
# blender_shader_sockets would be the (O,R,M) sockets.
-def gather_texture_info(primary_socket, blender_shader_sockets, export_settings):
- return __gather_texture_info_helper(primary_socket, blender_shader_sockets, 'DEFAULT', export_settings)
+def gather_texture_info(primary_socket, blender_shader_sockets, export_settings, filter_type='ALL'):
+ return __gather_texture_info_helper(primary_socket, blender_shader_sockets, 'DEFAULT', filter_type, export_settings)
-def gather_material_normal_texture_info_class(primary_socket, blender_shader_sockets, export_settings):
- return __gather_texture_info_helper(primary_socket, blender_shader_sockets, 'NORMAL', export_settings)
+def gather_material_normal_texture_info_class(primary_socket, blender_shader_sockets, export_settings, filter_type='ALL'):
+ return __gather_texture_info_helper(primary_socket, blender_shader_sockets, 'NORMAL', filter_type, export_settings)
-def gather_material_occlusion_texture_info_class(primary_socket, blender_shader_sockets, export_settings):
- return __gather_texture_info_helper(primary_socket, blender_shader_sockets, 'OCCLUSION', export_settings)
+def gather_material_occlusion_texture_info_class(primary_socket, blender_shader_sockets, export_settings, filter_type='ALL'):
+ return __gather_texture_info_helper(primary_socket, blender_shader_sockets, 'OCCLUSION', filter_type, export_settings)
@cached
@@ -34,16 +34,19 @@ def __gather_texture_info_helper(
primary_socket: bpy.types.NodeSocket,
blender_shader_sockets: typing.Tuple[bpy.types.NodeSocket],
kind: str,
+ filter_type: str,
export_settings):
- if not __filter_texture_info(primary_socket, blender_shader_sockets, export_settings):
- return None, None
+ if not __filter_texture_info(primary_socket, blender_shader_sockets, filter_type, export_settings):
+ return None, None, None
tex_transform, tex_coord, use_active_uvmap = __gather_texture_transform_and_tex_coord(primary_socket, export_settings)
+ index, factor = __gather_index(blender_shader_sockets, export_settings)
+
fields = {
'extensions': __gather_extensions(tex_transform, export_settings),
'extras': __gather_extras(blender_shader_sockets, export_settings),
- 'index': __gather_index(blender_shader_sockets, export_settings),
+ 'index': index,
'tex_coord': tex_coord
}
@@ -59,14 +62,14 @@ def __gather_texture_info_helper(
texture_info = gltf2_io.MaterialOcclusionTextureInfoClass(**fields)
if texture_info.index is None:
- return None, None
+ return None, None, None
export_user_extensions('gather_texture_info_hook', export_settings, texture_info, blender_shader_sockets)
- return texture_info, use_active_uvmap
+ return texture_info, use_active_uvmap, factor
-def __filter_texture_info(primary_socket, blender_shader_sockets, export_settings):
+def __filter_texture_info(primary_socket, blender_shader_sockets, filter_type, export_settings):
if primary_socket is None:
return False
if __get_tex_from_socket(primary_socket) is None:
@@ -75,9 +78,18 @@ def __filter_texture_info(primary_socket, blender_shader_sockets, export_setting
return False
if not all([elem is not None for elem in blender_shader_sockets]):
return False
- if any([__get_tex_from_socket(socket) is None for socket in blender_shader_sockets]):
- # sockets do not lead to a texture --> discard
- return False
+ if filter_type == "ALL":
+ # Check that all sockets link to texture
+ if any([__get_tex_from_socket(socket) is None for socket in blender_shader_sockets]):
+ # sockets do not lead to a texture --> discard
+ return False
+ elif filter_type == "ANY":
+ # Check that at least one socket link to texture
+ if all([__get_tex_from_socket(socket) is None for socket in blender_shader_sockets]):
+ return False
+ elif filter_type == "NONE":
+ # No check
+ pass
return True
@@ -163,7 +175,7 @@ def __gather_texture_transform_and_tex_coord(primary_socket, export_settings):
return texture_transform, texcoord_idx or None, use_active_uvmap
-
+# TODOExt deduplicate
def __get_tex_from_socket(socket):
result = gltf2_blender_search_node_tree.from_socket(
socket,