From a2c10e839c1058c47a00c8c8355a634fb47ae0db Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Sat, 9 May 2026 13:28:43 +0200 Subject: [PATCH 1/2] Basic KTX texture import --- addons/io_scene_gltf2/blender/imp/texture.py | 9 ++++++++- addons/io_scene_gltf2/io/imp/gltf2_io_gltf.py | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/io_scene_gltf2/blender/imp/texture.py b/addons/io_scene_gltf2/blender/imp/texture.py index d80c97390..a8c1c0ed0 100644 --- a/addons/io_scene_gltf2/blender/imp/texture.py +++ b/addons/io_scene_gltf2/blender/imp/texture.py @@ -215,10 +215,17 @@ def get_source(mh, pytexture): except Exception: webp_src = None + try: + ktx_src = pytexture.extensions['KHR_texture_basisu']['source'] + except Exception: + ktx_src = None + if mh.gltf.import_settings['import_webp_texture']: return webp_src if webp_src is not None else src + elif mh.gltf.import_settings['import_ktx_texture']: + return ktx_src if ktx_src is not None else src else: - return src if src is not None else webp_src + return src if src is not None else webp_src if webp_src is not None else ktx_src def set_filtering(tex_img, pysampler): diff --git a/addons/io_scene_gltf2/io/imp/gltf2_io_gltf.py b/addons/io_scene_gltf2/io/imp/gltf2_io_gltf.py index 774959a1c..04c2982ce 100644 --- a/addons/io_scene_gltf2/io/imp/gltf2_io_gltf.py +++ b/addons/io_scene_gltf2/io/imp/gltf2_io_gltf.py @@ -66,6 +66,7 @@ def __init__(self, filename, import_settings): 'KHR_animation_pointer', 'KHR_materials_volume', 'EXT_texture_webp', + "KHR_texture_basisu", 'KHR_materials_anisotropy', 'KHR_materials_dispersion', 'KHR_materials_iridescence', From c3866ddf159315c6d4d11999df4b348c47360768 Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Sat, 9 May 2026 13:32:58 +0200 Subject: [PATCH 2/2] Add option/UI for KTX import --- addons/io_scene_gltf2/__init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/io_scene_gltf2/__init__.py b/addons/io_scene_gltf2/__init__.py index ae3361591..6d5243860 100644 --- a/addons/io_scene_gltf2/__init__.py +++ b/addons/io_scene_gltf2/__init__.py @@ -1957,6 +1957,15 @@ class ImportGLTF2(Operator, ConvertGLTF2_Base, ImportHelper): default=False, ) + import_ktx_texture: BoolProperty( + name='Import KTX Textures', + description=( + "If a texture exists in KTX format, " + "loads the KTX texture instead of the fallback PNG/JPEG one" + ), + default=False, + ) + import_unused_materials: BoolProperty( name='Import Unused Materials & Images', description='Import materials & Images not assigned to any mesh', @@ -2129,6 +2138,7 @@ def import_texture_panel(layout, operator): if body: body.prop(operator, 'import_pack_images') body.prop(operator, 'import_webp_texture') + body.prop(operator, 'import_ktx_texture') body.prop(operator, 'import_unused_materials')