summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorLyuma <xn.lyuma@gmail.com>2023-01-30 23:37:55 -0800
committerLyuma <xn.lyuma@gmail.com>2023-02-01 01:42:36 -0800
commitbc24d0135944dedbdbaa8f6aff8f9faee772fe3e (patch)
tree48d03b8273c0ff940bba3c531dec26e62a4e41d3 /editor
parent0810ecaafdbee3ea747219e6ab3a8de5d2216a09 (diff)
gltf: Add GLTFHandleBinary::HANDLE_BINARY_EMBED_AS_UNCOMPRESSED
This option allows for a safe fallback for embedded gltf textures in cases where VRAM compression is not needed. Add an is_editor_hint guard around GLTFHandleBinary::HANDLE_BINARY_EXTRACT_TEXTURES, to use EMBED_AS_UNCOMPRESSED by default at runtime. This provides an option for pixel art to be stored losslessly. Additionally, respect project importer defaults for texture import settings. Avoid writing and reimporting extracted textures identical to version on disk.
Diffstat (limited to 'editor')
-rw-r--r--editor/import/resource_importer_scene.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 6c6c89bcc0..6fa37690c6 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -2289,7 +2289,14 @@ Node *ResourceImporterScene::pre_import(const String &p_source_file, const HashM
ERR_FAIL_COND_V(!importer.is_valid(), nullptr);
Error err = OK;
- Node *scene = importer->import_scene(p_source_file, EditorSceneFormatImporter::IMPORT_ANIMATION | EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS, p_options, nullptr, &err);
+ HashMap<StringName, Variant> options_dupe = p_options;
+
+ // By default, the GLTF importer will extract embedded images into files on disk
+ // However, we do not want the advanced settings dialog to be able to write files on disk.
+ // To avoid this and also avoid compressing to basis every time, we are using the uncompressed option.
+ options_dupe["gltf/embedded_image_handling"] = 3; // Embed as Uncompressed defined in GLTFState::GLTFHandleBinary::HANDLE_BINARY_EMBED_AS_UNCOMPRESSED
+
+ Node *scene = importer->import_scene(p_source_file, EditorSceneFormatImporter::IMPORT_ANIMATION | EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS, options_dupe, nullptr, &err);
if (!scene || err != OK) {
return nullptr;
}