Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gltf: Add GLTFHandleBinary::HANDLE_BINARY_EMBED_AS_UNCOMPRESSED #72440

Merged
merged 1 commit into from
Feb 1, 2023

Conversation

lyuma
Copy link
Contributor

@lyuma lyuma commented Jan 31, 2023

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.
Threw in another check to avoid overwriting and reimporting textures which were already extracted & identical to what is on disk.

editor import settings showing new embed as uncompressed option

Fixes #72200
Fixes #72195
Fixes #72467
Fixes #72191

@lyuma lyuma force-pushed the gltf_embed_as_uncompressed branch from 595f284 to 95569f5 Compare January 31, 2023 09:04
@akien-mga akien-mga added this to the 4.0 milestone Jan 31, 2023
@lyuma lyuma force-pushed the gltf_embed_as_uncompressed branch from 95569f5 to 5213d84 Compare January 31, 2023 09:50
@@ -87,7 +87,7 @@ Node *EditorSceneFormatImporterGLTF::import_scene(const String &p_path, uint32_t

void EditorSceneFormatImporterGLTF::get_import_options(const String &p_path,
List<ResourceImporter::ImportOption> *r_options) {
r_options->push_back(ResourceImporterScene::ImportOption(PropertyInfo(Variant::INT, "meshes/handle_gltf_embedded_images", PROPERTY_HINT_ENUM, "Discard All Textures,Extract Textures,Embed As Basis Universal", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), GLTFState::HANDLE_BINARY_EXTRACT_TEXTURES));
r_options->push_back(ResourceImporterScene::ImportOption(PropertyInfo(Variant::INT, "meshes/handle_gltf_embedded_images", PROPERTY_HINT_ENUM, "Discard All Textures,Extract Textures,Embed As Basis Universal,Embed as Uncompressed", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), GLTFState::HANDLE_BINARY_EXTRACT_TEXTURES));
Copy link
Member

@reduz reduz Jan 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a GLTF section for this, such as:
gltf/embedded_image_handling instead of taking over the mesh section. We already do this for Blender files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to use this name

@lyuma lyuma force-pushed the gltf_embed_as_uncompressed branch from 5213d84 to e66560c Compare January 31, 2023 10:38
@lyuma lyuma force-pushed the gltf_embed_as_uncompressed branch 3 times, most recently from 83d7767 to 0a2a6f7 Compare February 1, 2023 08:59
@lyuma
Copy link
Contributor Author

lyuma commented Feb 1, 2023

Updated the PR to also respect project import defaults. It will reimport them with Detect 3D after the gltf completes, which should be okay since it will run multithreaded, and avoids some hardcoded constants.

The original code set "compress/mode" to 2 but wrote remap instead of params, so it didn't actually work. Now that I'm reading the project defaults, there isn't a clean way to override the compression mode without disregarding the user's project settings, so I removed that part.

@lyuma lyuma force-pushed the gltf_embed_as_uncompressed branch from 0a2a6f7 to 122a40c Compare February 1, 2023 09:41
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.
@lyuma lyuma force-pushed the gltf_embed_as_uncompressed branch from 122a40c to bc24d01 Compare February 1, 2023 09:43
@akien-mga akien-mga requested a review from reduz February 1, 2023 10:48
@akien-mga akien-mga merged commit c400205 into godotengine:master Feb 1, 2023
@akien-mga akien-mga deleted the gltf_embed_as_uncompressed branch February 1, 2023 11:10
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment